Registry / web-framework / dot
library0.3.0jsnpmunverified

doT.js (pronounced "dot") is a lightweight, concise, and exceptionally fast JavaScript templating engine. It is designed to work seamlessly in both Node.js and browser environments, distinguishing itself by compiling templates into pure JavaScript functions, which contributes to its minimal overhead and high performance. The current stable release series is 1.x, with version 1.1.3 being the latest maintenance release, offering robust CommonJS and global browser compatibility. Development is active on version 2.x, currently in beta (2.0.0-beta.1), which introduces significant enhancements such as ES6 code generation, official TypeScript typings, and improved argument handling. doT.js maintains a conservative release cadence for major versions, prioritizing stability and efficiency. Its primary differentiators are its speed, minimal footprint, and lack of external dependencies, making it a strong choice for performance-sensitive applications where simplicity is key.

npm install dot
INSTALL
IMPORT
SIG · DOT
D
dot
web-frameworkjavascriptv0.3.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.

template
import { template } from 'dot';
const doT = require('dot'); const template = doT.template;
v2.x introduces official ESM exports. For v1.x, `require('dot')` returns the doT object, and `doT.template` is accessed from there.
process
import { process } from 'dot';
const doT = require('dot'); doT.process(...);
The `process` utility is part of the core doT object. In v2.x, it's a named export, while in v1.x, it's accessed via the default CommonJS import.
DoTTemplateFunction
import type { DoTTemplateFunction } from 'dot';
Available since v2.x, which ships with official TypeScript declaration files. Provides type safety for compiled template functions.

Demonstrates basic template compilation and rendering using the `template` function, including both `it` context and multi-argument destructuring, as well as a more complex example with control flow.

import { template } from 'dot'; // Basic usage with 'it' context const basicTmpl = template('Hello, {{=it.name}}!'); console.log(basicTmpl({ name: 'World' })); // Usage with explicit argName (v2.x feature, fallback for v1.x) const multiArgTmpl = template( 'User ID: {{=id}}, Username: {{=username}}', { argName: ['id', 'username'] } // This option is 'varname' in v1.x ); console.log(multiArgTmpl({ id: 123, username: 'jsuser' })); // A more complex example with conditionals and loops const listTmpl = template(` <h2>{{=it.title}}</h2> <ul> {{~it.items :item:idx}} <li>{{=idx + 1}}. {{=item}}</li> {{~}} </ul> {{? it.footer}} <p>{{=it.footer}}</p> {{?}} `); const data = { title: 'My Shopping List', items: ['Apples', 'Milk', 'Bread'], footer: 'Happy shopping!' }; console.log(listTmpl(data));
Debug
Known issues
breakingThe template option `varname` was renamed to `argName` in v2.0.0-beta.1. Templates created with `varname` in v1.x will not work as expected if this option is used in v2.x.
fix
Update any usage of the `varname` option to `argName` when migrating to v2.x.
affects: >=2.0.0-beta.1
breakingVersion 2.x of doT.js generates ES6 code by default and ships with official TypeScript typings, shifting towards ESM. While CJS is still supported, users migrating from v1.x (which is primarily CJS-focused) might need to adjust import statements for optimal compatibility.
fix
Review import/require statements and update to `import { template } from 'dot';` for ESM environments, or ensure proper CommonJS interop is configured for mixed environments.
affects: >=2.0.0-beta.0
gotchadoT.js v2.0.0-beta.x versions are currently pre-release. They introduce new features and breaking changes, but should not be used in production environments without thorough testing due to potential instability or further API changes.
fix
For production systems, continue using the stable 1.x branch. Evaluate v2.x betas for future migration planning and testing only.
affects: >=2.0.0-beta.0
gotchaVersion 1.1.3 patched a code injection vulnerability related to prototype pollution (#291). Older versions are susceptible to this security issue.
fix
Ensure you are using doT.js version 1.1.3 or higher to mitigate the prototype pollution vulnerability. Upgrade immediately if on an older 1.x version.
affects: <1.1.3
Errors
Common errors & fixes
ReferenceError: doT is not defined
Attempting to use `doT.template` directly in an environment where `doT` is not globally available or correctly imported/required.
fix
For CommonJS (v1.x), ensure `const doT = require('dot');` is at the top of your file. For ESM (v2.x), use `import * as doT from 'dot';` or `import { template } from 'dot';` if only needing specific exports.
TypeError: doT.template is not a function
This typically occurs when `doT` is imported incorrectly, resulting in `doT` being undefined or an object without the `template` property, or attempting to use `require` on an ESM-only build.
fix
Verify your import statement matches your module system (CommonJS `require` for v1.x, ESM `import` for v2.x). Ensure you're accessing `template` from the correct object returned by the import.
Property 'varname' does not exist on type '{ argName: string[]; }'
Using the deprecated `varname` option for template arguments with doT.js v2.x in a TypeScript environment.
fix
Replace `varname` with `argName` in your template options object to align with the v2.x API. Example: `{ argName: ['foo', 'bar'] }`.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
dot — npm install dot · libregistry