Home

Awesome

jstransformer-nunjucks

Nunjucks support for JSTransformers.

Build Status Coverage Status NPM version

Installation

npm install jstransformer-nunjucks

API

const jstransformer = require('jstransformer')
const nunjucks = jstransformer(require('jstransformer-nunjucks'))

nunjucks.render('Hello, {{ name }}!', {name: 'World'}).body
//=> 'Hello, World!'

const options = {
  filters: { repeat: (str, num) => str.repeat(n || 2) }
};

nunjucks.render(
  '{{ "Hello, " | repeat(echoes + 1) }}{{ name }}!',
  options,
  {name: 'World', echoes: 2}
).body

//=> 'Hello, Hello, Hello, World!'

See the JSTransformers documentation for other API methods.

By default, this transformer matches the .njk and .nunjucks input file extensions, and outputs .html.

Available options

Many of the API methods accept an options dictionary object. The following option keys are supported:

License

MIT