Created
March 20, 2017 02:14
-
-
Save hirejohnsalcedo/1177d44ba495673beebe4b4b64affe85 to your computer and use it in GitHub Desktop.
gulp-hb .json to .hbs to .html
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
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