fileloader

2.0.0 • Public • Published

fileloader

NPM version build status Test coverage David deps npm download

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);

License

MIT

/fileloader/

    Package Sidebar

    Install

    npm i fileloader

    Weekly Downloads

    104

    Version

    2.0.0

    License

    MIT

    Last publish

    Collaborators

    • fengmk2
    • popomore