gitmyhub

nunjucks

JavaScript ★ 9.0k updated 4mo ago

A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)

A JavaScript templating engine from Mozilla that lets you build HTML pages with reusable layouts and variable data, inspired by Python's Jinja2. Works in Node.js and the browser.

JavaScriptNode.jssetup: easycomplexity 2/5

Nunjucks is a templating engine for JavaScript, maintained by Mozilla. A templating engine is a tool that lets you build HTML pages (or other text files) by combining a fixed structure with variable data. Instead of writing the same HTML repeatedly with slightly different content, you write the structure once using special placeholder syntax, and the engine fills in the values at runtime.

Nunjucks is inspired by Jinja2, a popular Python templating system, and brings a similar feature set to JavaScript. It supports template inheritance, which means you can define a base page layout and have other templates extend it, avoiding repeated code. It also handles asynchronous operations, which matters in JavaScript where many tasks happen in a non-blocking way.

It works both on the server side (in Node.js) and in the browser. Installation is a single command via npm, the standard JavaScript package manager. The documentation is hosted separately on GitHub Pages.

The README for this project is brief and points to the external documentation site for full details. This is a developer utility, not an end-user application.

Where it fits