在升级我的ember后,我一直收到这个错误:
template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?我的配置是:
ember 1.10.0
ember-data 1.0.0-beta.14.1
jquery 1.9.1在搜索此问题时,我似乎必须启用此功能
EmberENV: {
FEATURES: {
'ember-htmlbars': true
}
},但我们目前没有使用ember cli。我在http://emberjs.com/guides/configuring-ember/feature-flags/上读了一遍,然后尝试了一下:
var EmberENV = {FEATURES: {'ember-htmlbars': true}};
//var EmberENV = {ENABLE_ALL_FEATURES: true}; //tried this too
//Ember.FEATURES["ember-htmlbars"] = true; //tried this too
window.AS = Ember.Application.create({
..
});但这仍然没有帮助。那么启用功能的正确方法是什么呢?
谢谢你,小迪
更新:
我们正在通过grunt编译我们的hbs文件,我们只需要在package.json中更新这些文件:
"devDependencies": {
"grunt-ember-templates": "~0.5.0",
"ember-template-compiler": "~1.9.0-alpha",
....
}在我的gruntfile.js中,我不得不在我的emberTemaple中做了以下更改:
emberTemplates: {
options: {
templateCompilerPath: 'lib/ember/ember-template-compiler.js',
handlebarsPath: 'lib/handlebars/handlebars.js',
templateNamespace: 'HTMLBars',
templateName: function (sourceFile) {
...
}
},罗伯特杰克逊写了这些变化,但我似乎没有找到邮局的地址!这样我就可以把我的模板编译成合适的htmlbar格式。
发布于 2015-03-23 02:01:17
我也有同样的问题。对于我的解决方案,我去http://emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html和https://github.com/dgeb/grunt-ember-templates/pull/77寻求帮助,但我遇到的问题是我使用的是Handlebars3.0而不是2.0。
options:{
templateCompilerPath: 'ember-template-compiler.js',
handlebarsPath: 'handlebars.js',
}对于handlebarsPath,请确保使用的是Handlebars2.0。
https://stackoverflow.com/questions/28415203
复制相似问题