Operators
Comparison Operators
eq
{{$eq value1 value2}}
Evaluates to true
if value1
is equal to value2
.
Arguments
value1
A static value or a variable path
value2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($eq category "sports") }}Category is sports{{/if}}
ne
{{$ne value1 value2}}
Evaluates to true
if value1
is not equal to value2
.
Arguments
value1
A static value or a variable path
value2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($ne category "sports") }}Category is not sports{{/if}}
gt
{{$gt number1 number2}}
Evaluates to true
if number1
is greater than the number2
.
Arguments
number1
A static value or a variable path
number2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($gt grand_total 1500) }}Grand total is greater than 1500{{/if}}
lt
{{$lt number1 number2}}
Evaluates to true
if number1
is less than number2
.
Arguments
number1
A static value or a variable path
number2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($lt score 50) }}Score is less than 50{{/if}}
gte
{{$gte number1 number2}}
Evaluates to true
if number1
is greater than or equal to number2
.
Arguments
number1
A static value or a variable path
number2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($gte score 50) }}Score is greater than or equal to 50{{/if}}
lte
{{$lte number1 number2}}
Evaluates to true
if number1
is less than or equal to number2
.
Arguments
number1
A static value or a variable path
number2
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($lte score 50) }}Score is less than or equal to 50{{/if}}
Identity Operators
isNull
{{$isNull value}}
Evaluates to true
if value
is null.
Arguments
value
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($isNull category) }}Category is null{{/if}}
isNotNull
{{$isNotNull value}}
Evaluates to true
if value
is not null.
Arguments
value
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($isNotNull category) }}Category is not null{{/if}}
isNil
{{$isNil value}}
Evaluates to true
if value
is null
or undefined
.
Arguments
value
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($isNil category) }}Category is nil{{/if}}
isNotNil
{{$isNotNil value}}
Evaluates to true
if value
is not null
or undefined
.
Arguments
value
A static value or a variable path
Returns
(Boolean)
Example
{{#if ($isNotNil category) }}Category is not nil{{/if}}
isEmpty
{{$isEmpty path}}
Evaluates to true
if the value of the variable path
is undefined
, null
, an empty string (''
) , empty object ({}
), or an empty array ([]
).
Arguments
path
A path to a variable to check for a value
Returns
(Boolean)
Example
{{#if ($isEmpty category )}}Category is empty{{/if}}
isNotEmpty
{{$isNotEmpty value}}
Evaluates to true
if value
is not undefined
, null
, an empty string (''
), an empty object ({}
), and not an empty array ([]
).
Arguments
path
A path to a variable to check for a value
Returns
(Boolean)
Example
{{#if ($isNotEmpty category) }}Category is not empty{{/if}}
Array Operators
isIn
{{$isIn value array}}
Evaluates to true if value
is in array
.
Arguments
value
A static value or a variable path
array
Array of values to check for value
Returns
(Boolean)
Example
{{#if ($isIn "sports" categories) }}Sports is in categories{{/if}}
isNotIn
{{$isNotIn value array}}
Evaluates to true
if value
is not in array
.
Arguments
value
A static value or a variable path
array
Array of values to check for value
Returns
(Boolean)
Example
{{#if ($isNotIn "sports" categories)}}Sports is not in categories{{/if}}
String Operators
startsWith
{{$startsWith string1 string2}}
Evaluates to true
if string1
starts with string2
.
Arguments
string1
A static value or a variable path to check for string2
string2
A static value or a variable path to check for in string1
Returns
(Boolean)
Example
{{#if ($startsWith movie "Bourne") }}Movie starts with Bourne{{/if}}
endsWith
{{$endsWith string1 string2}}
Evaluates to true if string1
ends with string2
.
Arguments
string1
A static value or a variable path to check for string2
string2
A static value or a variable path to check for in string1
Returns
(Boolean)
Example
{{#if ($endsWith movie "Story") }}Movie ends with Story{{/if}}
contains
{{$contains string1 string2}}
Evaluates to true if string1
exists in string2
.
Arguments
string1
A static value or a variable path to check for string2
string2
A static value or a variable path to check for in string1
Returns
(Boolean)
Example
{{#if ($contains movie "Bronx") }}Movie contains Bronx{{/if}}
doesNotContain
{{$doesNotContain string1 string2}}
Evaluates to true
if string1
does not exist in string2
.
Arguments
string1
A static value or a variable path to check for string2
string2
A static value or a variable path to check for in string1
Returns
(Boolean)
Example
{{#if ($doesNotContian movie "Batman") }}Movie does not contain Batman{{/if}}
matches
{{$matches string expression}}
Returns true
if string
matches a regular expression.
Arguments
string
A static value or a variable path to evaluate the regular expression against
expression
Regular expression to evaluate
Returns
(Boolean)
Example
{{#if ($matches category "^spo.*") }}Category matches regular expression{{/if}}
Logical Operators
Logical operators can be used in conjunction with #if
statements and other operators to perform logical checks.
and
{{$and arg1 arg2 ...}}
Returns true
if all arguments
evaluate to true
Arguments
arg1
1st argument to evaluate
arg2
2nd argument to evaluate
...
Remaining arguments to evaluate
Returns
(Boolean)
Example
This example checks if the qty
is greater than 5 and the amount
is less than 200
{{$and ($gt qty 5) ($lt amount 200) }}
or
{{$or arg1 arg2 ...}}
Returns true
if any of the arguments
evaluate to true
Arguments
arg1
1st argument to evaluate
arg2
2nd argument to evaluate
...
Remaining arguments to evaluate
Returns
(Boolean)
Example
This example checks if the qty
is greater than 5 or the amount
is less than 200
{{$or ($gt qty 5) ($lt amount 200) }}
Last updated