2
votes

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. I read up on http://emberjs.com/guides/configuring-ember/feature-flags/ and then tried this :

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 :

"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 :

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! That way I got my templates to be compiled to proper htmlbars format.

1
Can you first try to set EmberENV.ENABLE_ALL_FEATURES = true to see whether that resolves the problem -- then you can work out a more specific solutionOren Hizkiya
I tried setting var EmberENV = {ENABLE_ALL_FEATURES: true}; before I call create on my app and still I get the same error.Deewendra Shrestha
Try removing var and just declaring EmberENV = {ENABLE_ALL_FEATURES: true}. Depending upon which version of ember you are using you can also try ENV = {ENABLE_ALL_FEATURES: true} without the Ember prefix.Oren Hizkiya
Tried both, still no luck :( . I am using ember 1.10.0 with ED 1.0.0-beta.14.1 and jquery 1.9.1Deewendra Shrestha
It maybe that because we use grunt to compile our hbs files, and we have not updated our config as mentioned emberjs.com/blog/2015/02/05/compiling-templates-in-1-10-0.html, we are seeing this issue. I will make these changes and see if that resolves the issue. thanks @OrenDeewendra Shrestha

1 Answers

0
votes

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.

options:{ 
    templateCompilerPath: 'ember-template-compiler.js',
     handlebarsPath: 'handlebars.js',
}

for the handlebarsPath make sure you are using handlebars 2.0.