Reputation: 69
I have a view of the handlebars, I want to be in it was checking whether a variable IF js == 'foo'
<div class="title"><label for="inputSearch">{{#if variable == 'foo'}} AAA {{else}} BB {{/if}}</label></div>
<ul class="top-buttons">
<li class="back"><a href="#" id="priev_es">Wstecz</a></li>
<li class="more"></li>
</ul>
</div>
But I have this error in the console:
handlebars.js:286Error: Parse error on line 2:
{{#if variable == 'foo'}} AAA {{else
----------------^
Expecting 'DATA', 'STRING', 'INTEGER', 'BOOLEAN', 'ID', got 'EQUALS'
Upvotes: 2
Views: 2528
Reputation: 41
you have got to send in arguments to the annonymous function that you have bound to the name 'language' and then compare those 2 args and return true or false. According to the returned value use if else in handlebars
Upvotes: 0
Reputation: 943568
Handlebars has no in-built syntax for performing equality checks.
You have to put that sort of logic in your JavaScript, not your template.
You can express it as a helper that you can call from your template though.
Upvotes: 1