fly-nunjucks-render
v2.1.0
Published
Render Nunjucks templates with Fly!
Downloads
5
Maintainers
Readme
fly-nunjucks-render
Render Nunjucks templates with Fly.
Issues with the output should be reported on the Nunjucks issue tracker.
Install
npm install --save-dev fly-nunjucks-render
Usage
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>
API
.nunjucks(options)
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
.
options.base
Type: string
Default: .
Specify the location of your templates. Without this, Nunjucks will not be able to reliably compile or find your partials.
options.data
Type: object
Default: {}
Context data that is passed to your templates. Optional
option.dataPath
Type: string
Default: ''
Similar to options.data
, but is a path to an external file. Useful for large datasets. Optional
License
MIT © Luke Edwards