Serhii
Serhii

Reputation: 864

Jade, gulp-jade locals update

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

Answers (1)

rawllick
rawllick

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

Related Questions