fileloader
v2.0.0
Published
more stable file loader for nunjucks, and support charsets like `gbk`.
Downloads
451
Readme
fileloader
more stable file loader for nunjucks, and support charsets like gbk
.
Install
$ npm install fileloader
Usage
const nunjucks = require('nunjucks');
const FileLoader = require('fileloader');
const cluster = require('cluster');
let watch = true;
if (cluster.isWorker) {
watch = function(dirs, listener) {
process.on('message', msg => {
if (msg && msg.action === 'watch-file') {
console.warn('got master file change message: %j', msg.info);
listener(msg.info);
}
});
};
}
const dirs = ['/foo', '/bar/cms'];
const charsets = {
'/bar/cms': 'gbk'
};
const fileloader = new FileLoader(dirs, watch, charsets);
const env = new nunjucks.Environment(fileloader);