Render Nunjucks templates with Fly.
Issues with the output should be reported on the Nunjucks issue tracker.
npm install --save-dev fly-nunjucks-render
exports.views = function * (fly) {
yield fly.source('src/*.html')
.nunjucks({
base: 'src/partials',
data: {name: 'Luke Edwards'},
// or
dataPath: 'src/path/to/data.json'
})
.target('dist');
}
<!-- src/index.html -->
<p>Hello, {{ name }}!</p>
Multiple configuration options for Nunjucks are available.
Important: Please do not attempt to use the
watch
option. Instead, usefly.watch()
.
See below for additional options specific to fly-nunjucks-render
.
Type: string
Default: .
Specify the location of your templates. Without this, Nunjucks will not be able to reliably compile or find your partials.
Type: object
Default: {}
Context data that is passed to your templates. Optional
Type: string
Default: ''
Similar to options.data
, but is a path to an external file. Useful for large datasets. Optional
MIT © Luke Edwards