На данный момент у меня есть только две задачи с глотком, ex gulp.task('handlebars-index')
, gulp.task('handlebars-about')
. Ниже приведен код из документов, https://www.npmjs.org/package/gulp-compile-handlebarsGulp-compile-handlebars для нескольких html-страниц?
Я не уверен, как я могу справиться с задачей для двух файлов .handlebars.
var gulp = require('gulp');
var handlebars = require('gulp-compile-handlebars');
var rename = require('gulp-rename');
gulp.task('handlebars', function() {
var templateData = {
firstName: 'Kaanon'
},
options = {
ignorePartials: true, //ignores the unknown footer2 partial in the handlebars template, defaults to false
partials : {
footer : '<footer>the end</footer>'
},
batch : ['./src/partials'],
helpers : {
capitals : function(str){
return str.toUpperCase();
}
}
}
// here how do I add an index.html and say and about.html?
return gulp.src('src/index.handlebars')
.pipe(handlebars(templateData, options))
.pipe(rename('index.html'))
.pipe(gulp.dest('dist'));
});
Вы можете увидеть выше задачи в основном берет index.handlebars затем компилирует его и создает файл index.html.
Если бы я добавил массив файлов руля, как эта задача будет знать, как создать .html-версию?
return gulp.src(['src/index.handlebars','src/about.handlebars'])
.pipe(handlebars(templateData, options))
.pipe(rename('index.html'))
.pipe(rename('about.html'))
.pipe(gulp.dest('dist'));
Вышеуказанное не будет работать.
Хорошо, хорошо выглядит благодаря, верные удары, имеющие 3-4 глотком задачи БЖ. Я должен был больше обратить внимание на плагин Gulp-rename, я чистил документы gulp-compile-handlebars. Спасибо, человек, которого вы качаете! –