2
votes

How do I handle the error:

TypeError: compile is not a function
template = compile(script.html());

in ember-1.0.0-rc.1.js?

The included frameworks are:

jquery-1.9.1.js

handlebars.1.0.0-rc.3.js

ember-1.0.0-rc.1.js

1
No. The bold text is 1:1 copied from the firebug output. But I think you are right, executed is Handlebars.compile(...). At the moment, I try to follow what James suggested. Ember.Handlebars.compile(...). Unfortunately, up to now without success.Daniel

1 Answers

3
votes

Ember only requires the Handlebars runtime (available as handlebars.runtime.js from http://handlebarsjs.com). If you want to do template compilation in the browser (as opposed to precompiling all templates and shipping the resulting JavaScript to the browser), you will need to include the full Handlebars on the page and change compile to Ember.Handlebars.compile. (Ember.Handlebars.compile wraps Handlebars.compile in some Ember-specific magic.)

For example,

<script src="/assets/jquery-1.9.js"></script>
<script src="/assets/handlebars-1.0.0-rc.3.js"></script>
<script src="/assets/ember-1.0.0-rc.1.js"></script>

and

MyView = Ember.View.extend({
  template: Ember.Handlebars.compile("{{foo}} {{bar}}"),
});