Assemble 车把模板相对于它的路径
Assemble handlebar template relative to its path
所以我试图浏览一个目录并编译所有 hbs 文件。但问题是 hbs 文件应该在它所在的文件夹中编译。
伪代码:
assemble: {
options: {
flatten: false,
assets: 'assets',
dev: true,
livereloadPort: '<%- livereloadPort %>',
partials: ['dev/assemble/partials/*.hbs'],
layout: 'dev/assemble/banner.hbs',
data: ['dev/assemble/data/*.{json,yml}']
},
// ----------------------------------------------------------------
// assembles
dev: {
options: {
data: ['dev/assemble/data/*.{json,yml}']
},
src: ['dev/banners/**/*.hbs'],
expand: true,
dest: '<% SAME AS SRC FILE %>',
ext: '.html'
}
},
基本上就是这个文件夹结构;
/横幅/
/bannerfolder_1/
handlebarfile.hbs
/bannerfolder_2/
另一个_handlebarfile.hbs
会导致这样;
/横幅/
/bannerfolder_1/
handlebarfile.hbs
handlebarfile.html
/bannerfolder_2/
另一个_handlebarfile.hbs
another_handlebarfile.html
能做到吗?
试试下面的方法globbing pattern / dynamic mapping
files: {
expand: true, // Enable dynamic expansion.
cwd: 'dev/', // Src matches are relative to this path.
src: ['banners/**/*.hbs'], // Actual pattern(s) to match.
dest: 'dev/', // Destination path prefix.
ext: '.html', // Dest filepaths will have this extension.
extDot: 'last' // Extensions in filenames begin after the last dot
}
所以我试图浏览一个目录并编译所有 hbs 文件。但问题是 hbs 文件应该在它所在的文件夹中编译。
伪代码:
assemble: {
options: {
flatten: false,
assets: 'assets',
dev: true,
livereloadPort: '<%- livereloadPort %>',
partials: ['dev/assemble/partials/*.hbs'],
layout: 'dev/assemble/banner.hbs',
data: ['dev/assemble/data/*.{json,yml}']
},
// ----------------------------------------------------------------
// assembles
dev: {
options: {
data: ['dev/assemble/data/*.{json,yml}']
},
src: ['dev/banners/**/*.hbs'],
expand: true,
dest: '<% SAME AS SRC FILE %>',
ext: '.html'
}
},
基本上就是这个文件夹结构;
/横幅/
/bannerfolder_1/
handlebarfile.hbs
/bannerfolder_2/
另一个_handlebarfile.hbs
会导致这样;
/横幅/
/bannerfolder_1/
handlebarfile.hbs
handlebarfile.html
/bannerfolder_2/
另一个_handlebarfile.hbs
another_handlebarfile.html
能做到吗?
试试下面的方法globbing pattern / dynamic mapping
files: {
expand: true, // Enable dynamic expansion.
cwd: 'dev/', // Src matches are relative to this path.
src: ['banners/**/*.hbs'], // Actual pattern(s) to match.
dest: 'dev/', // Destination path prefix.
ext: '.html', // Dest filepaths will have this extension.
extDot: 'last' // Extensions in filenames begin after the last dot
}