我有src/data/mydata.json
个文件包含此内容(从getting json data into assemble templates in grunt复制)
{
"name": "This is a square widget",
"modifier": "widget-square"
}
当我尝试在somepage.hbs
中使用它时,我什么都没得到
<div class="col-md-5">
{{mydata.name}}
</div>
为什么?
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
assemble: {
options: {
assets: "dist/assets",
dara: "src/data/*.json",
layoutdir: "src/layouts/",
flatten: true
},
pages: {
options: {
layout: "page.hbs"
},
files: {
"dist/": ["src/*.hbs", "!src/index.hbs" ]
}
},
homepage: {
options: {
layout: "homepage.hbs"
},
files: {
"dist/": ["src/index.hbs" ]
}
}
},
copy: {
assets: {
files: [
{ expand: true, cwd: "src/assets/", src: ["**"], dest: "dist/assets/" }
]
}
},
watch: {
scripts: {
files: 'src/**',
tasks: ['assemble', 'copy'],
options: {
}
}
}
});
grunt.loadNpmTasks('grunt-assemble' );
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['assemble', 'copy' ]);
};
答案 0 :(得分:1)
我的Gruntfile
,da r a而不是da t a只是一个错误类型。修好之后看起来效果很好。