Toggle menu

Comparisons

Conditionally render blocks if the comparison is met. Includes "is", "isn't", "greater than", "less than", "or" and "and".

is

Conditionally render a block if the condition is true.

Parameters

value [string|int] - the value to test against. 

Example

number = 5

{{#is number 5}}
  Oranges and Lemons
{{else}}
  Never mind
{{/is}}

Result

Oranges and Lemons

isnt

Conditionally render a block if the condition is false. 

Parameters

value [string|int] - the value to test against.

Example

number = 5

{{#isnt number 5}}
  Oranges and Lemons
{{else}}
  Never mind
{{/isnt}}

Result

Never mind

gt

Conditionally render a block if the value is greater than a given number.

Parameters

value [string|int] - the value to test against.

Example

number = 5

{{#gt number 8}}
  Oranges and Lemons
{{else}}
  Never mind
{{/gt}}

Result

Never mind

gte

Conditionally render a block if the value is greater than or equal to a given number.

Parameters

value [string|int] - the value to test against.

Example

number = 5

{{#gte number 5}}
  Oranges and Lemons
{{else}}
  Never mind
{{/gte}}

Result

Oranges and Lemons

lt

Conditionally render a block if the value is less than a given number.

Parameters

value [string|int] - the value to test against.

Example

number = 5

{{#lt number 3}}
  Oranges and Lemons
{{else}}
  Never mind
{{/lt}}

Result

Never mind

lte

Conditionally render a block if the value is less than or equal to a given number. 

Parameters

value [string|int] - the value to test against.

Example

number = 5

{{#lte number 5}}
  Oranges and Lemons
{{else}}
  Never mind
{{/lte}}

Result

Oranges and Lemons

or

Conditionally render a block if one of the values is truthy.

Parameters

values [string|int] - the values to test against.

Example

great = no
magnificent = true

{{#or great magnificent}}
  Oranges and Lemons
{{else}}
  Never mind
{{/or}}

Result

Oranges and Lemons

and

Conditionally render a block if both values are truthy.

Parameters

values [string|int] - the values to test against.

Example

great = true
magnificent = true

{{#and great magnificent}}
  Oranges and Lemons
{{else}}
  Never mind
{{/and}}

Result

Oranges and Lemons

Last modified on May 31, 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon