Operators

Comparison Operators

eq

{{$eq value1 value2}}

Evaluates to true if value1 is equal to value2.

Arguments

NameDescriptionTypeRequired

value1

A static value or a variable path

StringNumberBoolean

value2

A static value or a variable path

StringNumberBoolean

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

NameDescriptionTypeRequired

value1

A static value or a variable path

StringNumberBoolean

value2

A static value or a variable path

StringNumberBoolean

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

NameDescriptionTypeRequired

number1

A static value or a variable path

Number

number2

A static value or a variable path

Number

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

NameDescriptionTypeRequired

number1

A static value or a variable path

Number

number2

A static value or a variable path

Number

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

NameDescriptionTypeRequired

number1

A static value or a variable path

Number

number2

A static value or a variable path

Number

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

NameDescriptionTypeRequired

number1

A static value or a variable path

Number

number2

A static value or a variable path

Number

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

NameDescriptionTypeRequired

value

A static value or a variable path

Any

Returns

(Boolean)

Example

{{#if ($isNull category) }}Category is null{{/if}}

isNotNull

{{$isNotNull value}}

Evaluates to true if value is not null.

Arguments

NameDescriptionTypeRequired

value

A static value or a variable path

Any

Returns

(Boolean)

Example

{{#if ($isNotNull category) }}Category is not null{{/if}}

isNil

{{$isNil value}}

Evaluates to true if value is null or undefined .

Arguments

NameDescriptionTypeRequired

value

A static value or a variable path

Any

Returns

(Boolean)

Example

{{#if ($isNil category) }}Category is nil{{/if}}

isNotNil

{{$isNotNil value}}

Evaluates to true if value is not null or undefined.

Arguments

NameDescriptionTypeRequired

value

A static value or a variable path

Any

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

NameDescriptionTypeRequired

path

A path to a variable to check for a value

Any

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

NameDescriptionTypeRequired

path

A path to a variable to check for a value

Any

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

NameDescriptionTypeRequired

value

A static value or a variable path

StringNumberBoolean

array

Array of values to check for value

String ArrayNumber ArrayBoolean Array

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

NameDescriptionTypeRequired

value

A static value or a variable path

StringNumberBoolean

array

Array of values to check for value

String ArrayNumber ArrayBoolean Array

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

NameDescriptionTypeRequired

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

(Boolean)

Example

{{#if ($startsWith movie "Bourne") }}Movie starts with Bourne{{/if}}

endsWith

{{$endsWith string1 string2}}

Evaluates to true if string1 ends with string2.

Arguments

NameDescriptionTypeRequired

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

(Boolean)

Example

{{#if ($endsWith movie "Story") }}Movie ends with Story{{/if}}

contains

{{$contains string1 string2}}

Evaluates to true if string1 exists in string2.

Arguments

NameDescriptionTypeRequired

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

(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

NameDescriptionTypeRequired

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

(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

NameDescriptionTypeRequired

string

A static value or a variable path to evaluate the regular expression against

String

expression

Regular expression to evaluate

String

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

NameDescriptionTypeRequired

arg1

1st argument to evaluate

Boolean

arg2

2nd argument to evaluate

Boolean

...

Remaining arguments to evaluate

Boolean

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

NameDescriptionTypeRequired

arg1

1st argument to evaluate

Boolean

arg2

2nd argument to evaluate

Boolean

...

Remaining arguments to evaluate

Boolean

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