jeudi 19 février 2015

Ember.js — Change context within template like each block, but for single item

Is there a way to set an individual controller/model as the context within a template, in the same way the context is set with an {{#each}} loop?


The reason I want to do this is that I have a collection I iterate over with each, and then a very similar object i want to render a partial for as well.


In the each loop im using partial, I want to use the same partial for the extra single object. I know I can use a partial call within the loop and a render call outside with the context passed as an argument — but it feels weird treating a partial file as a template for render.



{{ render "website/redirect" webHomeTemplate }}
{{#each webPageTemplates}}
{{ partial "website/redirect" }}
{{/each}}

Aucun commentaire:

Enregistrer un commentaire