Skip to content

Instantly share code, notes, and snippets.

@hirejohnsalcedo
Created March 20, 2017 02:14
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 hirejohnsalcedo/1177d44ba495673beebe4b4b64affe85 to your computer and use it in GitHub Desktop.
Save hirejohnsalcedo/1177d44ba495673beebe4b4b64affe85 to your computer and use it in GitHub Desktop.
gulp-hb .json to .hbs to .html
function posts() {
return gulp.src('./src/data/*.json')
.pipe(through.obj(function (file, enc, cb) {
var name = path.parse(file.path).name;
var data = JSON.parse(String(file.contents));
gulp.src('./src/templates/*.hbs')
.pipe(hb().data(data))
.pipe(rename({
basename: name,
extname: '.html',
}))
.pipe(gulp.dest('./dist'))
.on('error', cb)
.on('end', cb);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment