O'Reilly logo

Mastering Ember.js by Mitchel Kelonye

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying a view's template

Every view renders a template into the DOM. Views can be assigned the template to use in a number of ways. For example, let's consider the following router:

App.Router.map(function(){
  this.route('new');
});

Ember.js will expect a defined App.NewRoute class for the new route as:

App.NewRoute = Ember.Route.extend({
  model: function(){
    return Em.Object.create();
  }
});

Any visit to this route will use the following Ember.js objects, if defined:

  • The App.NewController object
  • The Ember.TEMPLATES.new template
  • The App.NewView object

The default behavior is where the name of the template dictates the view to use. If we wish to use a different template, say Ember.TEMPLATES.form, we will need to implement it in the renderTemplates hook ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required