javascript - Within gulpfile, pass JSON object to task -


in code below, make task calls javascript function buildtemplate pass json object to. ideally, however, i'd replace function build-template task pass object instead. possible? also, adding javascript functions supplement gulpfile i'm doing considered bad practice?

var gulp = require('gulp'); // include plugins var concat = require('gulp-concat'); var sass = require('gulp-sass');  var templates = require('./config/templates.json');  // watch files changes gulp.task('watch', function() {   gulp.watch('./input/structure/*/*.liquid', ['make']); });  gulp.task('make', function() {   // list of templates (pull config file)   (var = 0; < templates.length; i++) {     var template = templates[i];     buildtemplate(template);   }; });  // default task gulp.task('default', [   'make',   'watch' ]);  // helper function function buildtemplate(template) {   var template_title = template['title'];   gulp.src(     [       './input/structure/snippets/header.liquid',       './input/structure/templates/' + template_title + '.liquid',       './input/structure/snippets/footer.liquid'     ])     .pipe(concat(template_title + '.html'))     .pipe(gulp.dest('./output/')   ); }; 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -