Developer docs


Usage: {{#unless featured}}{{/unless}}

The {{#unless}} block helper comes built in with Handlebars.


{{#unless}} is essentially the opposite of {{#if}}. If you want to test a negative conditional only, i.e. if you only need the {{else}} part of an {{#if}} statement, then {{#unless}} is what you need.

It works exactly the same as {{#if}} and supports both {{else}} and ^ negation if you want to get really confusing!

Unless also uses the exact same conditional evaluation rules as {{#if}}.

Example code

Basic unless example, will execute the template between its start and end tags only if featured evaluates to false.

{{#unless featured}} something...

If you want, you can also include an else block, although in the majority of cases, if you need an else, then using {{#if}} is more readable:

<!-- This is identical to if, but with the blocks reversed -->
{{#unless featured}} thing 1...
{{else}} thing 2...