I am trying to display each file in gulp source files with its own json file, but I cannot figure out how to access the current file name in pipe .
var gulp = require('gulp'); var handlebars = require('handlebars'); var gulpHandlebars = require('gulp-compile-handlebars'); gulp.task('compile-with-sample-data', function () { var options = {} return gulp.src('./src/**/*.html') .pipe(gulpHandlebars({ data: require('./data/' + filename +'.json') }, options)) .pipe(gulp.dest('./build/')); });
Where can I get it to work with the same file every time, simply using require('./data/orders-complete.json') :
var gulp = require('gulp'); var handlebars = require('handlebars'); var gulpHandlebars = require('gulp-compile-handlebars'); gulp.task('compile-with-sample-data', function () { var options = {} return gulp.src('./src/**/*.html') .pipe(gulpHandlebars({ data: require('./data/orders-complete.json') }, options)) .pipe(gulp.dest('./build/')); });
It is not clear how I will do this.
javascript gulp
JP Silvashy
source share