ember.jshtmlbars

Ember.HTMLBars.compile is undefined in Ember 2.7


In our application we use the template compiler at runtime by calling Ember.HTMLBars.compile with a handlebars template. Example code:

let myTemplate = `{{foo}}`;
application.register(`template:my-template`, Ember.HTMLBars.compile(myTemplate));

I've tried to upgrade from Ember 2.6 to Ember 2.7 but I get the following error in the developer console if I try to compile the template:

_ember.default.HTMLBars.compile is not a function()

In the documentation I couldn't find anything about the compile method being removed from the HTMLBars compiler.

How can I still use/enable the HTMLBars compiler at runtime in my application?


Solution

  • import original ember-template-compiler.js in ember-cli-build.js

    app.import('bower_components/ember/ember-template-compiler.js');