sindresorhus / gulp-nunjucks

Precompile Nunjucks templates
MIT License
152 stars 20 forks source link

Allow custom template context #5

Closed bnjmnt4n closed 8 years ago

bnjmnt4n commented 8 years ago

Would be great if you could allow users to specify custom context for Nunjucks through something like gulp-data.

sindresorhus commented 8 years ago

Sure, pull request welcome :)

You can see how it's implemented here: https://github.com/sindresorhus/gulp-template/blob/cec7e127bf1acf371c33f1a5beec0f7b3b6e329d/index.js#L21 https://github.com/sindresorhus/gulp-template/blob/cec7e127bf1acf371c33f1a5beec0f7b3b6e329d/test.js#L23-L176

bnjmnt4n commented 8 years ago

Will work on it and send it in soon ;)

bnjmnt4n commented 8 years ago

Hmm, appears I read the readme wrongly. I thought this plugin was used to compile Nunjucks templates, didn't realise it was used for precompiling only. I'm not too sure about gulp plugins, should I create another one or just add it as a feature for this plugin?

sindresorhus commented 8 years ago

Add it as a feature. See gulp-template on how it was done there ;)

bnjmnt4n commented 8 years ago

What would the API be like? nunjucks and nunjucks.precompile like gulp-template or something like nunjucks and nunjucks.compile to maintain API consistency?

sindresorhus commented 8 years ago

I would go with nunjucks.compile and nunjucks.precompile and preserve nunjucks for backwards compatibility.