您好,我创建应用程序,我现在需要定义新布局,我在 grunt 文件中使用此代码
assemble: {
pages: {
options: {
flatten: true,
assets: '<%= config.dist %>/assets',
layout: '<%= config.src %>/templates/layouts/default.hbs',
data: '<%= config.src %>/data/*.{json,yml}',
partials: '<%= config.src %>/templates/partials/{,*/}*.hbs'
},
files: {
'<%= config.dist %>/': ['<%= config.src %>/templates/pages/*.hbs']
}
}
},
现在我阅读了文档http://assemble.io/docs/Layouts.html并输入了这样的必要代码。
assemble: {
pages: {
options: {
flatten: true,
assets: '<%= config.dist %>/assets',
layout: '<%= config.src %>/templates/layouts/default.hbs',
data: '<%= config.src %>/data/*.{json,yml}',
partials: '<%= config.src %>/templates/partials/{,*/}*.hbs'
},
files: {
'<%= config.dist %>/': ['<%= config.src %>/templates/pages/*.hbs']
}
},
simple: {
options: {
assets: '<%= config.dist %>/assets',
layout: '<%= config.src %>/templates/layouts/simple.hbs',
data: '<%= config.src %>/data/*.{json,yml}',
partials: '<%= config.src %>/templates/partials/{,}*.hbs'
},
files: {
'<%= config.dist %>/': ['<%= config.src %>/templates/pages/simple/*.hbs']
}
}
},
基本上,我声明新布局简单,并尝试强制生成的模板位于同一目录中,但结果是 - dist/src/templates/pages/simple/name_of_file.html 此代码在默认情况下有效,但在其他布局中无效。
有什么帮助吗?这是否可能我有解决方法,但会很高兴完成这些事情。
没关系,我找到了解决方案
assemble: {
pages: {
options: {
flatten: false,
expand: true,
assets: '<%= config.dist %>/assets',
layout: '<%= config.src %>/templates/layouts/default.hbs',
data: '<%= config.src %>/data/*.{json,yml}',
partials: '<%= config.src %>/templates/partials/{,*/}*.hbs'
},
files: [
{expand: true, cwd: '<%= config.src %>/templates/pages/', src: '**/*.hbs', dest: '<%= config.dist %>/', ext: '.html'}
]
},
simple: {
options: {
assets: '<%= config.dist %>/assets',
layout: '<%= config.src %>/templates/layouts/simple.hbs'
},
files: [
{expand: true, cwd: '<%= config.src %>/templates/pages/simple/', src: '**/*.hbs', dest: '<%= config.dist %>/', ext: '.html'}
]
}
},