TheOnly92
TheOnly92

Reputation: 1763

Helpers not properly defined in application template?

I'm extremely new to ember.js and am hitting a wall. I'm using ember.js 1.0.0-pre4

My app.js has the following setup:

window.App = Ember.Application.create();

App.Router.map(function() {
    this.route("dashboard", {path: "/"});
});

App.DashboardRoute = Ember.Route.extend({
})

I tried doing something like this on the application template (Ember.TEMPLATES['application'])

{{#linkTo "dashboard"}}Dashboard{{/linkTo}}

And it gives me Uncaught Error: Could not find property 'linkTo'. I tried {{view}} as well as other helpers but all gave me the same could not find property error.

jsfiddle: http://jsfiddle.net/gBf42/

Upvotes: 0

Views: 591

Answers (1)

DF_
DF_

Reputation: 3973

Aha, I found the problem! When you use Handlebars.compile it uses the handlebars script instead of the Ember script. Ember has its own handlebars object that extends the original Handlebars object with extra templates. One such template is the {{#linkTo ...}} template.

So to fix, all you have to do is use Ember.Handlebars instead:

Ember.TEMPLATES["application"] = Ember.Handlebars.compile("{{#linkTo 'dashboard'}}Dashboard{{/linkTo}}")

Upvotes: 3

Related Questions