Created
December 26, 2014 17:06
-
-
Save aereal/f9537a85b8395dea4981 to your computer and use it in GitHub Desktop.
This file contains 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 path = require('path'); | |
var gulp = require('gulp'); | |
var data = require('gulp-data'); | |
var handlebars = require('gulp-compile-handlebars'); | |
var rename = require('gulp-rename'); | |
gulp.task('default', ['html']); | |
gulp.task('html', function () { | |
var defaultData = { | |
url: 'http://aereal.org/', | |
}; | |
var handlebarOptions = {}; | |
return gulp.src(['templates/**/*.hbs']) | |
.pipe(data(function (file) { | |
return require(metadataFile(file.path)); | |
})) | |
.pipe(handlebars(defaultData, handlebarOptions)) | |
.pipe(rename(htmlify)) | |
.pipe(gulp.dest('dist')); | |
}) | |
function htmlify (path) { | |
path.extname = '.html'; | |
} | |
function metadataFile (templateFile) { | |
var base = path.basename(templateFile, '.hbs'); | |
return path.resolve(__dirname, 'data', base + '.json'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment