1

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?

Lebbers
  • 107
  • 7

3 Answers3

1

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

app.import('bower_components/ember/ember-template-compiler.js');
AHOYAHOY
  • 1,856
  • 4
  • 24
  • 34
1

I was needed to compile template during runtime und used https://www.npmjs.com/package/ember-cli-handlebars-inline-precompile. Try this:

import hbs from 'htmlbars-inline-precompile';
application.register(`template:my-template`, hbs`{{foo}}`);
0

Since there is less information provided, first try and check the error source.

presumably a library it is, you need to open your developers console [lets say chrome] and then click on the error which will direct you to where the error originates from so you can adjust or rectify the code...

apexpals.com
  • 305
  • 1
  • 11
  • The question is about how to resolve the error (which I found in the developer console). The point is that HTMLBars doens't provide the method compile anymore (in Ember 2.7.0) which it did before (Ember 2.6.2) – Lebbers Sep 15 '16 at 11:29