Open jgatjens opened 7 years ago
Install gulp-data: npm i -D gulp-data
npm i -D gulp-data
In the gulpfile.babel import the module and the data you want to pass to the templates.
import data from 'gulp-data'; import jsonData from './src/path/to/json';
Edit the nunjucks task to add the data
gulp.task('nunjucks', () => { // Gets .html and .nunjucks files in pages return gulp.src(src.nunjucks) // Adding data to Nunjucks .pipe(data(function() { return jsonData; })) // Renders template with nunjucks .pipe(nunjucksRender({ path: [src.templates] })) // output files in app folder .pipe(gulp.dest(src.root)); });
i dont care.
Nice!! Thanks! @Marcotss Grow up! :D
Install gulp-data:
npm i -D gulp-data
In the gulpfile.babel import the module and the data you want to pass to the templates.
Edit the nunjucks task to add the data