carlitoplatanito / gulp-nunjucks-render

[Gulp](https://github.com/wearefractal/gulp) plugin to render [Nunjucks](http://mozilla.github.io/nunjucks/) templates
149 stars 33 forks source link

Allow to configure default options for multiple rendering #41

Closed antonfisher closed 8 years ago

antonfisher commented 8 years ago

Hello Carlos, What do you think about configurable default options? I implemented this for multiple rendering:

var nunjucksRender = require('gulp-nunjucks-render');

template1.pipe(nunjucksRender({
  path: ['/templates'], // repeat or merge with different 'data' property
  envOptions: {         
    autoescape: false
  },
  data: {...}
}));
...
templateN.pipe(nunjucksRender({
  path: ['/templates'], // repeat or merge with different 'data' property
  envOptions: {
    autoescape: false
  },
  data: {...}
}));

Will be replaced with:

var nunjucksRender = require('gulp-nunjucks-render');

nunjucksRender.setDefaults({
  path: ['/templates'],
  envOptions: {
    autoescape: false
  }
});

template1.pipe(nunjucksRender({data: {...}}));
...
templateN.pipe(nunjucksRender({data: {...}}));

Thank you.

carlitoplatanito commented 8 years ago

Thanks I like this. I have to find time to document it before updating it to NPM and bumping the version though.