【发布时间】:2014-04-19 15:12:56
【问题描述】:
所以我已经有了这个运行良好的 grunt-contrib-jade 设置
当我自己将数据包含在(导出的)Gruntfile 中时,一切都很好:
module.exports = {
website: {
options: {
data: {
pageTitle: "This is my website",
greeting: "Hello world",
},
debug: true,
pretty: true
},
files: {
'build/website/index.html': 'src/jade/template/index.jade'
}
}
};
它将我的 index.jade 与我的数据值合并,我的 index.html 输出是它应该的方式。但是当我想加载一个外部文件来定义我的数据时,它出错了:
options: {
data: function (dest, src) {
// Return an object of data to pass to templates
return require('src/jade/template/locals.json');
},
debug: true,
pretty: true
},
files: {
'build/website/index.html': 'src/jade/template/index.jade'
}
需要的路径是有效的,我检查了三次。它与我的 index.jade 位于同一文件夹中。但是我仍然不断收到此错误:
Running "jade:website" (jade) task
>> Jade failed to compile "src/jade/template/index.jade".
>> Error: Cannot find module './locals.json'
>> Destination not written because compiled files were empty.
我几乎尝试了所有方法,但我没有看到。
【问题讨论】:
标签: gruntjs