Last active
August 29, 2015 14:19
-
-
Save shannonmoeller/bb9ce397d5be3fa8d493 to your computer and use it in GitHub Desktop.
Many data sources to one template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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