Skip to content

Instantly share code, notes, and snippets.

@shannonmoeller
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shannonmoeller/bb9ce397d5be3fa8d493 to your computer and use it in GitHub Desktop.
Save shannonmoeller/bb9ce397d5be3fa8d493 to your computer and use it in GitHub Desktop.
Many data sources to one template
var gulp = require('gulp');
var hb = require('gulp-hb');
var rename = require('gulp-rename');
var through = require('through2');
gulp.task('build', function () {
return gulp
.src('./data/**/*.json')
.pipe(through.obj(function(file, enc, cb) {
var data = JSON.parse(String(file.contents));
file.contents = new Buffer('{{> template file.data}}');
file.data = data;
cb(null, file);
}))
.pipe(hb({
partials: './template.hbs'
}))
.pipe(rename({
extname: '.html'
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment