管理使用一飲而盡組裝,以解決這個問題,他們對如何開始https://www.npmjs.com/package/gulp-assemble
一個很好的說明。如果有興趣的人,這是所使用的格式:
var gulp = require('gulp');
var rename = require('gulp-rename');
var assemble = require('assemble');
var helpers = require('handlebars-helpers');
var app = assemble();
var prettify = require('gulp-prettify');
var config = require('../config');
gulp.task('init', function(cb) {
app.helper('compare', helpers.comparison());
app.helper('markdown', require('helper-markdown'));
app.partials(config.paths.path_src + 'templates/includes/**/*.hbs');
app.layouts(config.paths.path_src + 'templates/layouts/**/*.hbs');
app.pages(config.paths.path_src + 'templates/content/**/*.hbs');
cb();
});
gulp.task('assemble', ['init'], function() {
return app.toStream('pages')
.pipe(app.renderFile())
.pipe(prettify({
indent_inner_html: false,
preserve_newlines: true,
end_with_newline: true,
extra_liners: ['head', 'body']
}))
.pipe(rename({
extname: '.html'
}))
.pipe(rename({dirname: ''}))
.pipe(app.dest('site'));
});
gulp.task('test', ['assemble']);
和你的HBS頁面將如下:
---
layout: default
title: Blank
heading: Blank
pagedescription: blank desc
---
{{#*inline "head-block"}}test-head{{/inline}}
{{#*inline "scripts-block"}}test-foot{{/inline}}
test file