使用gulp编译手柄在子目录中批处理嵌套模板

使用gulp编译手柄在子目录中批处理嵌套模板,gulp,handlebars.js,Gulp,Handlebars.js,我正在使用gulp compileHandlebars来编译我的handlebars模板,并使用json数据创建一个页面,这非常有效。。。问题是我想将我的Handlebar模板嵌套在子目录中,但当我这样做时,批处理过程在我将:*/*.Handlebar添加到批处理路径后再也找不到模板。见下文: gulp.task('compileHandlebars', function () { delete require.cache[require.resolve('./src/layout.js

我正在使用gulp compileHandlebars来编译我的handlebars模板,并使用json数据创建一个页面,这非常有效。。。问题是我想将我的Handlebar模板嵌套在子目录中,但当我这样做时,批处理过程在我将:*/*.Handlebar添加到批处理路径后再也找不到模板。见下文:

gulp.task('compileHandlebars', function () {
    delete require.cache[require.resolve('./src/layout.json')]
    var buildSettings = require('./src/layout.json');
    var templateData = buildSettings,
    options = {
        batch : ['./src/assets/templates/**/*.handlebars']
    }

    gulp.src('./src/index.handlebars')
        .pipe(handlebars(templateData, options))
        .pipe(rename('index.html'))
        .pipe(cleanhtml())
        .pipe(gulp.dest('./dist'))
        .pipe(livereload());
});
on npm表示批处理需要一个文件路径数组,但示例显示了一个带有目录路径的数组。您的示例使用的是blob语法,这是行不通的。看起来批处理也不会递归地查看子目录。。。因此,我认为您必须创建一个数组,其中包含每个Handlebar文件的父目录路径

我知道,这是一件很糟糕的事。但是,您可能可以使用自动检索把手文件路径的过程,并从每个路径中切掉文件名以获得目录数组