0.0.16 • Published 6 years ago
nunjucks-watch v0.0.16
nunjucks-watch
Auto updator for Nunjucks. It resolves location of dependents relative to the rendering target and watch them with chokidar.
Install
npm install nunjucks-watch
Usage
Write result to a file
const nunjucksWatch = require('nunjucks-watch');
const watcher = nunjucksWatch.watch({
src: 'path/to/your/template.nunjucks',
dest: 'path/to/dest.html',
context: {
foo: 'burn'
}
});
Receive result as a string
const nunjucksWatch = require('nunjucks-watch');
const watcher = nunjucksWatch.watch({
src: 'path/to/your/template.nunjucks',
context: {
foo: 'burn'
}
})
.on('update', function (rendered) {
console.log(rendered);
});
API
nunjucksWatch.watch(options)
Start an updator.
options
Type: Object
options.src
Type: String
(required)
A path to a file to be rendered.
options.dest
Type: String
(optional)
A path to which an updator will write the rendered text.
options.context
Type: Object
(optional)
options.context
will be used as a context object on rendering.
options.environment
Type: Object
(optional)
options.environment
will be passed to the nunjucks.Environment constructor.
options.fsLoader.debounce
Type: Number
(optional)
Time to wait for debouncing (milliseconds).
License
MIT