Computer User
Computer User

Reputation: 546

How do I check if a variable is falsey in handlebars?

I want to do something like this but it is invalid.

{{if ! notification}}

I am working on an old system and notification could be null, false or undefined. How do I check if this variable is falsey?

Upvotes: 0

Views: 259

Answers (1)

Rahil Wazir
Rahil Wazir

Reputation: 10132

You can use unless block helper which is the opposite of if block helper

{{#unless notification}}
    // Your content
{{/unless}}

Upvotes: 2

Related Questions