Registry / serialization / tmpl
library1.1.0jsnpmunverified

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.

npm install tmpl
INSTALL
IMPORT
SIG · TMPL
T
tmpl
serializationjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tmpl
const tmpl = require('tmpl');
import tmpl from 'tmpl';
The `tmpl` package is a CommonJS module. Direct ESM imports will fail in native ESM environments without a bundler or transpiler.
tmpl (destructuring)
const renderTemplate = require('tmpl');
const { tmpl } = require('tmpl');
`tmpl` exports a single function as its default, not a named export. Destructuring will assign `undefined`.

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}
Debug
Known issues
breakingThe `tmpl` package is abandoned, with its last release (1.0.5) over a decade ago in 2013. This poses significant security risks due to unpatched vulnerabilities and ensures incompatibility with modern JavaScript features and environments.
fix
It is strongly recommended to migrate away from `tmpl`. Replace its usage with native JavaScript template literals (`` `string ${variable}` ``) or a well-maintained, modern templating library. Conduct a dependency audit to identify if `tmpl` is a direct or transitive dependency and plan for its removal.
affects: >=1.0.0
gotchaThis package is designed for CommonJS environments and does not provide native ECMAScript Module (ESM) support. Attempting to `import tmpl from 'tmpl'` in a Node.js project configured for native ESM (`'type': 'module'` in `package.json`) will result in a runtime error.
fix
For direct usage in CommonJS, use `const tmpl = require('tmpl');`. In ESM projects, either use a bundler that can transpile CommonJS to ESM, or ideally, replace `tmpl` with native template literals.
affects: >=1.0.0
gotchaNo TypeScript type definitions (`.d.ts` files) are shipped with the `tmpl` package, nor are they available on DefinitelyTyped. Using `tmpl` in a TypeScript project will result in type errors.
fix
You will need to create a custom declaration file (e.g., `tmpl.d.ts`) to provide types. For example: `declare module 'tmpl' { function tmpl(template: string, data?: object): string; export = tmpl; }`.
affects: >=1.0.0
deprecatedNative JavaScript template literals (introduced in ES6/ES2015) provide a more idiomatic, performant, and secure way to achieve string interpolation (e.g., `` `Hello ${name}!` `` vs. `tmpl('Hello {name}!', { name })`).
fix
For new code, always prefer native template literals. For existing code, refactor to use template literals wherever possible.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require()` in a native ES module environment (e.g., when `package.json` has `"type": "module"`).
fix
Ensure your project is configured for CommonJS or use a bundler that can handle CommonJS modules within an ESM context. For new code, prefer native ES module `import` statements and template literals.
TypeError: tmpl is not a function
Incorrectly attempting to invoke `tmpl` as a constructor (`new tmpl(...)`) or destructuring it incorrectly (e.g., `const { tmpl } = require('tmpl');`).
fix
`tmpl` exports a single function as its default. Ensure you are importing it correctly as a default CommonJS export and calling it directly: `const result = tmpl('...', data);`.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
tmpl — npm install tmpl · libregistry