H
H
Help Center
Docs
Ask or search…
K
Links
Comment on page

Operators

Comparison Operators

eq

{{$eq value1 value2}}
Evaluates to true if value1 is equal to value2.
Arguments
Name
Description
Type
Required
value1
A static value or a variable path
String
Number
Boolean
value2
A static value or a variable path
String
Number
Boolean
Returns
Example
Template
Data
Result
{{#if ($eq category "sports") }}Category is sports{{/if}}
{
"category":"sports"
}
Category is sports

ne

{{$ne value1 value2}}
Evaluates to true if value1 is not equal to value2.
Arguments
Name
Description
Type
Required
value1
A static value or a variable path
String
Number
Boolean
value2
A static value or a variable path
String
Number
Boolean
Returns
Example
Template
Data
Result
{{#if ($ne category "sports") }}Category is not sports{{/if}}
{
"category":"sports"
}
This is a sports category

gt

{{$gt number1 number2}}
Evaluates to true if number1 is greater than the number2.
Arguments
Name
Description
Type
Required
number1
A static value or a variable path
Number
number2
A static value or a variable path
Number
Returns
Example
Template
Data
Result
{{#if ($gt grand_total 1500) }}Grand total is greater than 1500{{/if}}
{
"grand_total": 1600
}
Grand total is greater than 1500

lt

{{$lt number1 number2}}
Evaluates to true if number1 is less than number2.
Arguments
Name
Description
Type
Required
number1
A static value or a variable path
Number
number2
A static value or a variable path
Number
Returns
Example
Template
Data
Result
{{#if ($lt score 50) }}Score is less than 50{{/if}}
{
"score": 25
}
Score is less than 50

gte

{{$gte number1 number2}}
Evaluates to true if number1 is greater than or equal to number2.
Arguments
Name
Description
Type
Required
number1
A static value or a variable path
Number
number2
A static value or a variable path
Number
Returns
Example
Template
Data
Result
{{#if ($gte score 50) }}Score is greater than or equal to 50{{/if}}
{
"score": 50
}
Score is greater than or equal to 50

lte

{{$lte number1 number2}}
Evaluates to true if number1 is less than or equal to number2.
Arguments
Name
Description
Type
Required
number1
A static value or a variable path
Number
number2
A static value or a variable path
Number
Returns
Example
Template
Data
Result
{{#if ($lte score 50) }}Score is less than or equal to 50{{/if}}
{
"score":50
}
Content to display for sports

Identity Operators

isNull

{{$isNull value}}
Evaluates to true if value is null.
Arguments
Name
Description
Type
Required
value
A static value or a variable path
Any
Returns
Example
Template
Data
Result
{{#if ($isNull category) }}Category is null{{/if}}
{
"category": null
}
Category is null

isNotNull

{{$isNotNull value}}
Evaluates to true if value is not null.
Arguments
Name
Description
Type
Required
value
A static value or a variable path
Any
Returns
Example
Template
Data
Result
{{#if ($isNotNull category) }}Category is not null{{/if}}
{
"category": "sports"
}
Category is

isNil

{{$isNil value}}
Evaluates to true if value is null or undefined .
Arguments
Name
Description
Type
Required
value
A static value or a variable path
Any
Returns
Example
Template
Data
Result
{{#if ($isNil category) }}Category is nil{{/if}}
{
"category":null
}
Category is nil

isNotNil

{{$isNotNil value}}
Evaluates to true if value is not null or undefined.
Arguments
Name
Description
Type
Required
value
A static value or a variable path
Any
Returns
Example
Template
Data
Result
{{#if ($isNotNil category) }}Category is not nil{{/if}}
{
"category":"sports"
}
Category is not nil

isEmpty

{{$isEmpty path}}
Evaluates to true if the value of the variable path is undefined or not included in the data set.
Arguments
Name
Description
Type
Required
path
A path to a variable to check for a value
Any
Returns
Example
Template
Data
Result
{{#if ($isEmpty category )}}Category is empty{{/if}}
{
"name":"soccer"
}
Category is empty

isNotEmpty

{{$isNotEmpty value}}
Evaluates to true if value is undefined or not included in the data set.
Arguments
Name
Description
Type
Required
path
A path to a variable to check for a value
Any
Returns
Example
Template
Data
Result
{{#if ($isNotEmpty category) }}Category is not empty{{/if}}
{
"category":"sports"
}
Category is not empty

Array Operators

isIn

{{$isIn value array}}
Evaluates to true if value is in array.
Arguments
Name
Description
Type
Required
value
A static value or a variable path
String
Number
Boolean
array
Array of values to check for value
String Array
Number Array
Boolean Array
Returns
Example
Template
Data
Result
{{#if ($isIn "sports" categories) }}Sports is in categories{{/if}}
{
"categories":[
"sports",
"entertainment",
"news"
]
}
Sports is in categories

isNotIn

{{$isNotIn value array}}
Evaluates to true if value is not in array.
Arguments
Name
Description
Type
Required
value
A static value or a variable path
String
Number
Boolean
array
Array of values to check for value
String Array
Number Array
Boolean Array
Returns
Example
Template
Data
Result
{{#if ($isNotIn "sports" categories)}}Sports is not in categories{{/if}}
{
"categories":[
"entertainment",
"weather",
"news"
]
}
Sports is not in categories

String Operators

startsWith

{{$startsWith string1 string2}}
Evaluates to true if string1 starts with string2.
Arguments
Name
Description
Type
Required
string1
A static value or a variable path to check for string2
String
string2
A static value or a variable path to check for in string1
String
Returns
Example
Template
Data
Result
{{#if ($startsWith movie "Bourne") }}Movie starts with Bourne{{/if}}
{
"movie":"Bourne Identity"
}
Movie starts with Bourne

endsWith

{{$endsWith string1 string2}}
Evaluates to true if string1 ends with string2.
Arguments
Name
Description
Type
Required
string1
A static value or a variable path to check for string2
String
string2
A static value or a variable path to check for in string1
String
Returns
Example
Template
Data
Result
{{#if ($endsWith movie "Story") }}Movie ends with Story{{/if}}
{
"movie":"Toy Story"
}
Movie ends with Story

contains

{{$contains string1 string2}}
Evaluates to true if string1 exists in string2.
Arguments
Name
Description
Type
Required
string1
A static value or a variable path to check for string2
String
string2
A static value or a variable path to check for in string1
String
Returns
Example
Template
Data
Result
{{#if ($contains movie "Bronx") }}Movie contains Bronx{{/if}}
{
"movie":"A Bronx Tale"
}
Movie contains Bronx

doesNotContain

{{$doesNotContain string1 string2}}
Evaluates to true if string1 does not exist in string2.
Arguments
Name
Description
Type
Required
string1
A static value or a variable path to check for string2
String
string2
A static value or a variable path to check for in string1
String
Returns
Example
Template
Data
Result
{{#if ($doesNotContian movie "Batman") }}Movie does not contain Batman{{/if}}
{
"movie":"The Dark Knight"
}
Movie does not contain Batman

matches

{{$matches string expression}}
Returns true if string matches a regular expression.
Arguments
Name
Description
Type
Required
string
A static value or a variable path to evaluate the regular expression against
String
expression
Regular expression to evaluate
String
Returns
Example
Template
Data
Result
{{#if ($matches category "^spo.*") }}Category matches regular expression{{/if}}
{
"category":"sports"
}
Category matches regular expression

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
Name
Description
Type
Required
arg1
1st argument to evaluate
Boolean
arg2
2nd argument to evaluate
Boolean
...
Remaining arguments to evaluate
Boolean
Returns
Example
This example checks if the qty is greater than 5 and the amount is less than 200
Template
Data
Result
{{$and ($gt qty 5) ($lt amount 200) }}
{
"amount": 150,
"qty": 4
}
true

or

{{$or arg1 arg2 ...}}
Returns true if any of the arguments evaluate to true
Arguments
Name
Description
Type
Required
arg1
1st argument to evaluate
Boolean
arg2
2nd argument to evaluate
Boolean
...
Remaining arguments to evaluate
Boolean
Returns
Example
This example checks if the qty is greater than 5 or the amount is less than 200
Template
Data
Result
{{$or ($gt qty 5) ($lt amount 200) }}
{
"amount": 500,
"qty": 4
}
true