mercredi 7 janvier 2015

How do I output an opening or closing tag in an ember handlebars if block?

I am trying to use a Zurb Foundation grid in ember, and I can't figure out how to get my template to properly insert row start/end tags with multiple columns.


I have a controller properly spitting out "isFirst, isFirstOfRow, isLast, isLastOfRow", but I can't figure out how to get Ember's version of handlebars to spit out unbalanced opening/closing tags. My logic will balance them, but they won't be balanced in each iteration of the {{#each}} block.


My template looks like this:



{{#each item in items}}
<li>
These are all working perfectly, thanks to my mad math skills:
{{project.first}}
{{project.firstOfRow}}
{{project.last}}
{{project.lastOfRow}}
{{_view.contentIndex}}

The problems start here:
{{#if item.firstOfRow}}
<ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-4">
I shouldn't be closed immediately
{{/if}}

<a href="/items/{{unbound id}}">
<div class="panel text-center">
<h4>{{item.title}}</h4>
<p>{{item.description}}</p>
<p>Story Count: {{item.storyCount}}</p>
</div>
</a>

...and continue here:
{{#if item.lastOfRow}}
I should have been closed here.
Ember outputs an unbalanced closing tag correctly,
it's the opening that has the problem!
</ul>
{{/if}}
</li>
{{else}}
<ul><div class="text-center"><strong>No items found</strong></div></ul>
{{/each}}


It keeps immediately closing the <ul> tag at the top.


Is there a way to cause the ember template to output the HTML, but treat it dumbly, as if it were plain text?





Aucun commentaire:

Enregistrer un commentaire