tmpl JavaScript Micro Templating

1.0.5 · abandoned · verified Sun Apr 19

The `tmpl` package, version 1.0.5, is a minimalist JavaScript micro-templating utility last updated in 2013. Its primary function is basic string interpolation, replacing `{}` placeholders in a template string with corresponding values from a provided data object. This library offers a very limited feature set compared to more robust templating engines like Handlebars or EJS, lacking control flow, iteration, or helper functions. Developed before the widespread availability of native JavaScript template literals (ES6 backticks), `tmpl` is now largely superseded by built-in language features for new development. The project is considered abandoned, with no active maintenance, security updates, or new releases since its last version over a decade ago. While still accumulating significant weekly downloads, this is primarily due to its presence as a transitive dependency in older projects. It functions exclusively within CommonJS environments and offers no native support for ECMAScript Modules (ESM) or TypeScript.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic string interpolation using a template string and a data object, showing how placeholders are replaced or retained if data is missing.

const tmpl = require('tmpl');

const templateString = 'Hello, {name}! Your age is {age}.';
const data = { name: 'Alice', age: 30 };

const result = tmpl(templateString, data);

console.log(result);
// Expected output: Hello, Alice! Your age is 30.

// Example with missing data - placeholders are left as is
const incompleteResult = tmpl('Missing: {missingKey}', { name: 'Bob' });
console.log(incompleteResult);
// Expected output: Missing: {missingKey}

view raw JSON →