Rendering a specific model in template slot


#1

May be a simple question, but it’s probably an unusual requirement.

Inside a template I can simply iterate through each of the models and everything works ok. eg:

{{#each model}}
  <li>{{title}}</li>
{{/each}}

However, I have a particular layout where I need to use predefined slots for the model to appear. To do this i need to access the model array by index, I think this is possible in handlebars, but probably because model is not a standard array I can’t seem to find a suitable solution. Here’s the concept that I would need to use…

<div class="slot1">
    {{#with model.[0]}}
      <h3>{{title}}</h3>
    {{/with}}
  </div>

Any ideas as to how to achieve this?


#2

Instead of trying to do this in your template. You might want to override your Route’s renderTemplate hook and manually render the template. This way, you’ll have control over what gets loaded into what area of the template.

Take a look at the Rendering Template page in the Route Guide.