Wjst is an awesome, Django/Jinja-like template engine for node.js.
- Available for node.js and major web browsers!
- Express compatible.
- Object-Oriented template inheritance.
- Apply filters and transformations to output in your templates.
- Automatically escapes all output for safe HTML rendering.
- Lots of iteration and conditionals supported.
- Robust without the bloat.
- Extendable and customizable. See Wjst-Extras for some examples.
- Great code coverage.
npm install wjst
All documentation can be viewed online on the Wjst Website.
<h1>{{ pagename|title }}</h1>
<ul>
{% for author in authors %}
<li{% if loop.first %} class="first"{% endif %}>{{ author }}</li>
{% endfor %}
</ul>
const wjst = require('wjst');
const template = wjst.compileFile('./index.html');
const output = template({
pagename: 'awesome people',
authors: ['Den', 'Paul', 'Jane']
});
<h1>Awesome People</h1>
<ul>
<li class="first">Den</li>
<li>Paul</li>
<li>Jane</li>
</ul>
For working example see examples/basic
Wjst reads template files and translates them into cached javascript functions. When we later render a template we call the evaluated function, passing a context object as an argument.