gulp-data
gulp-data copied to clipboard
Empty HTML
My problem is that my views:build
task includes the templates before the data gets injected, resulting in a blank html page. What am i doing wrong?
This is my code:
gulp.task('views:build', ['views:templates'] , () => {
return gulp.src(config.views.src + '*.twig')
.pipe($.data(function() {
return JSON.parse(fs.readFileSync('src/data/timber.json'))
})) // load data from base json file
.pipe($.twig())
.pipe(gulp.dest(config.views.tmp))
.pipe(reload({stream: true}));
});
gulp.task('views:templates', () => {
return gulp.src(config.views.src + 'templates/*.twig')
.pipe($.data(function(file) {
return JSON.parse(fs.readFileSync('src/data/' + path.basename(file.path).replace('.twig', '')
+ '.json'));
}))
.pipe($.twig())
.pipe(gulp.dest(config.views.tmp))
});