javascript - Handlebars expression outside of #each helper -


how can add dynamic class name in #each block handlebars template, class name isn't part of block scope?

<div class="{{classname}}>...</div>  {{#each items}}     <div class="{{classname}}">         ...     </div> {{/each}} 

the first <div> see class name, whereas second 1 in #each block doesn't, because looking classname in items.
possible see outside of items scope in #each block?

you need go 1 scope (or possibly more), using ../ access global variable. in case if pass classname 1 attribute , ìtems`as another, code should this:

{{#each items}}    <div class="{{../classname}}">     ...    </div> {{/each}} 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -