Reputation: 864
is any solution to update locals for jade templates for every build (even if watch jade file)? Now, templates get data only on first build.
Upvotes: 2
Views: 1280
Reputation: 146
I had the same problem. So here's your answer:
var fs = require('fs');
/*
* Views
*/
gulp.task('views', function () {
return gulp.src(o.views.src)
.pipe(p.jade({
locals: JSON.parse(fs.readFileSync(o.views.data, 'utf8'))
}))
.pipe(gulp.dest(o.dest));
});
o.views.data - path to json file, e.g. './src/data/data.json'
Upvotes: 2