Conditionals Using conditional statements inside templates Guide
Categories

Conditionals

Control Structures

Templates support common control structures like if, elseif and else to handle branching paths in your template.

{#if isEven number}
Even
{else if isZero number}
Zero
{else}
Odd
{/if}

Conditional Syntax

Expressions support both lisp-like and javascript syntax wherever expressions are used including in conditionals.

{#if isEqual(a, b) }
A is B
{else if isEqual a c}
A is C
{/if}

Conditional Helpers

Template helpers can be used to make your templates easier to read and to provide common utilities like checking if a value is empty.

For a full list of comparators view the dedicated section on comparison helpers

With Helpers
{#if is valueA valueB}
Values are equal
{/if}
{#if not isEven number}
Odd
{else}
Even
{/if}
No Helpers
{#if valueA == valueB}
Values are equal
{/if}
{#if !isEven(number)}
Odd
{else}
Even
{/if}
Previous
Expressions
Next
Loops