jinja2 - How can I pass JSON data into a Nunjucks template? -


i want use nunjucks templates want pass in own json data used on templates.

the documentation here pretty sparse.

https://mozilla.github.io/nunjucks/templating.html

thank you.

you can use gulp-data allows pass json files task runner you're using render nunjucks.

gulp.task('nunjucks', function() {   return gulp.src('app/pages/**/*.+(html|nunjucks)')     // adding data nunjucks     .pipe(data(function() {       return require('./app/data.json')     }))     .pipe(nunjucksrender({       path: ['app/templates']     }))     .pipe(gulp.dest('app')) }); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -