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
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
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}}"),
});