[英]How to enable feature in ember to use htmlbars when not using ember cli or app kit
I have been getting this error after upgrading my ember : 升级余烬后,我一直收到此错误:
template must be a function. Did you mean to call Ember.Handlebars.compile("...") or specify templateName instead?
My configuration is: 我的配置是:
ember 1.10.0
ember-data 1.0.0-beta.14.1
jquery 1.9.1
Upon searching for this issue, it seems like I have to enable feature 搜索此问题后,似乎我必须启用该功能
EmberENV: {
FEATURES: {
'ember-htmlbars': true
}
},
but we are not using ember cli at this moment. 但目前我们不使用ember cli。 I read up on http://emberjs.com/guides/configuring-ember/feature-flags/ and then tried this :
我在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({
..
});
but this still didn't help. 但这仍然没有帮助。 So what is the correct way to enable feature?
那么启用功能的正确方法是什么?
Thanks, Dee 谢谢迪
UPDATE : 更新:
We were compiling our hbs files via grunt and we just needed to update these in package.json : 我们正在通过grunt编译我们的hbs文件,我们只需要在package.json中更新它们:
"devDependencies": {
"grunt-ember-templates": "~0.5.0",
"ember-template-compiler": "~1.9.0-alpha",
....
}
And in my gruntfile.js had to make following change in my emberTemaple : 在我的gruntfile.js中,必须在emberTemaple中进行以下更改:
emberTemplates: {
options: {
templateCompilerPath: 'lib/ember/ember-template-compiler.js',
handlebarsPath: 'lib/handlebars/handlebars.js',
templateNamespace: 'HTMLBars',
templateName: function (sourceFile) {
...
}
},
Robert Jackson wrote on these changes but I don't seem to find the address to the post! 罗伯特·杰克逊(Robert Jackson)写下了这些更改,但我似乎找不到该帖子的地址! That way I got my templates to be compiled to proper htmlbars format.
这样我就可以将模板编译为正确的htmlbars格式。
I had the same issue. 我遇到过同样的问题。 For my solution I went to http://emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html and https://github.com/dgeb/grunt-ember-templates/pull/77 for help but the issue that I had was I was using handlebars 3.0 and not 2.0.
对于我的解决方案,我去了http://emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html和https://github.com/dgeb/grunt-ember- templates / pull / 77寻求帮助,但是我遇到的问题是我使用的是车把3.0,而不是2.0。
options:{
templateCompilerPath: 'ember-template-compiler.js',
handlebarsPath: 'handlebars.js',
}
for the handlebarsPath make sure you are using handlebars 2.0. 对于handlebarsPath,请确保您使用的是handlebars 2.0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.