Reputation: 3479
I would like to know what is the correct syntax of this:
<li class="nav-item {{# if undefined !== user}} hidden {{/if}}">
I want to add class name hidden if user variable exists.
It displays an error:
Upvotes: 1
Views: 1508
Reputation: 40444
You can't use undefined !== user
expression, it's not valid syntax. The if
block helper will check for undefined, so there is no need for undefined !== user
, just use: {{#if user}}
<li class="nav-item {{#if user}}non-empty{{/if}}">
If you want to check if user
is empty you should use the unless
helper
<li class="nav-item {{#unless user}}empty-user{{/unless}}">
Here's is the code for the default if
helper, basically it will evaluate to true if non falsy value is passed.
Upvotes: 2