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 dotVerified import paths — ran on the pinned version, not inferred.
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.
Update any usage of the `varname` option to `argName` when migrating to v2.x.
Review import/require statements and update to `import { template } from 'dot';` for ESM environments, or ensure proper CommonJS interop is configured for mixed environments.For production systems, continue using the stable 1.x branch. Evaluate v2.x betas for future migration planning and testing only.
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.
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.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.
Replace `varname` with `argName` in your template options object to align with the v2.x API. Example: `{ argName: ['foo', 'bar'] }`.No dependency data recorded yet.