Have gulp / nunjucks iterate on a template based on json data file -


i using gulp-data attach json file file.data in gulp stream. want gulp read property data, render template value, increment value , repeat until condition met ( loop in js ). can nunjucks access data on file.data object, not gulp, , haven't found answered question getting gulp perform loop. i'm trying create static pages similar, except incrementing thru -01.html , -01.jpg each. here's basic idea far, not right , needs gulp-rename or similar well:

var getjsondata = function(file) {   return require(path.dirname(file.path) + '/' + path.basename(file.path, '.nunjucks') + '.json'); };   gulp.task('json', function() {   return gulp.src('./build/nunjucks/pages/**/*.nunjucks')     .pipe(data(getjsondata))     .pipe( gulpif(data.pages, function() {       (i = 0, < pages, i++) {         .pipe(nunjucksrender({           path: ['./build/nunjucks/templates']         }));         .pipe(gulp.dest('./build'));         data.number++;       }     }))      // need loop here     .pipe(nunjucksrender({       path: ['./build/nunjucks/templates']     }))     .pipe(gulp.dest('./build')); }); 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -