3
votes

I have an Ember.js route like this:

this.route 'doc', path: '/docs/:doc'

And I need to set the template based on the :doc param. How can I achieve this?

Thanks.

1
what does the model look like for this route? - Toran Billups
There isn't a model, so to speak. It's just for loading a template. Kinda like a static HTML page. - Michael Irwin

1 Answers

1
votes

Maybe you could try something like this:

  1. Set the desired templateName into your context/model in the property "templateName".
  2. In the View for your route access the context of the View (= your model) and read the property and set it as templateName of the View.

App.DocView = Ember.View.extend({
    render : function(buffer){
      var context = this.get("context.content");
      this.set("templateName", context);
      this._super(buffer);
    }
});

Link to Fiddle: http://jsfiddle.net/mavilein/DQ8gS/2/