How to judge wheather two variable equal in spacebar?

here ‘index’ is different on each loop

{{#each proposedVideosList}}
<a href="#" onclick="Session.set('videoNum',{{index}})">     
     <li class="{{#if {{index}}==Session.get('videoNum') }}    // 'index' is changing on each loop,how to judge if index //equal to 'videoNum' ? 
        		did-vote
        	{{/if}}">
        {{index}}
     </li>
</a >
{{/each}}

Hi, you can try this package.
https://atmospherejs.com/raix/handlebar-helpers

it works. thank you…

1 Like

Yes handlebar-helpers works but perhaps your own helper may be simpler, something like

<li class="{{#if videoNumEquals index  }}    // 'index' is changing
...
videoNumEquals: function(index) {
  return Session.get('videoNum') == index;
}

Me, I use a general comparison helper:

Template.registerHelper 'equals', (a,b) ->
	if a==b then true

and

{{#if equals helper1 helper2}}
   <render_something>
{{/if}
4 Likes