The Ghost Themes Developer Hub

Welcome to the Ghost Themes developer hub. You'll find comprehensive guides and documentation to help you start working with Ghost Themes as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    


{{unless}} Helper - reverse conditional helper (else block)

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


conditional value (any type)


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...

All block helpers also support negation, but now you really should be using if!!

// The negation symbol means that this is identical to using if
{{^unless featured}} thing 1...
{{else}} thing 2...


{{unless}} Helper - reverse conditional helper (else block)