Arithmetic Helpers

Arithmetic helpers provide basic mathematical operations for integer values.

HelperPurposeParametersReturns
incIncrements a numeric value by onevaluenumber
decDecrements a numeric value by onevaluenumber
addAdds two numeric valuesvalue1, value2number
subSubtracts a numeric value from anothervalue1, value2number
mulMultiplies two numeric valuesvalue1, value2number
divDivides one numeric value by anothervalue1, value2number
modModulus of two numeric valuesvalue1, value2number
absAbsolute value of a numeric valuevaluenumber

inc

Increments a numeric value by one.

Syntax:

{{#inc value}}

Parameters:

Returns: The incremented value as an integer.

Examples:

{{#inc 5}}                     {{!-- 6 --}}
{{#inc @index}}                {{!-- Current index + 1 --}}

dec

Decrements a numeric value by one.

Syntax:

{{#dec value}}

Parameters:

Returns: The decremented value as an integer.

Examples:

{{#dec 5}}                     {{!-- 4 --}}
{{#dec @index}}                {{!-- Current index - 1 --}}

add

Adds two numeric values together.

Syntax:

{{#add value1 value2}}

Parameters:

Returns: The sum of the two values as an integer.

Examples:

{{#add 5 10}}                  {{!-- 15 --}}
{{#add @index 2}}              {{!-- Current index + 2 --}}

sub

Subtracts the second numeric value from the first.

Syntax:

{{#sub value1 value2}}

Parameters:

Returns: The difference between the two values as an integer.

Examples:

{{#sub 10 5}}                   {{!-- 5 --}}
{{#sub @index 1}}               {{!-- Current index - 1 --}}

mul

Multiplies two numeric values together.

Syntax:

{{#mul value1 value2}}

Parameters:

Returns: The product of the two values as an integer.

Examples:

{{#mul 5 10}}                  {{!-- 50 --}}
{{#mul @index 2}}              {{!-- Current index * 2 --}}

div

Divides the first numeric value by the second.

Syntax:

{{#div value1 value2}}

Parameters:

Returns: The result of the division as an integer.

Examples:

{{#div 10 5}}                   {{!-- 2 --}}
{{#div @index 2}}               {{!-- Current index / 2 --}}

mod

Calculates the modulus of the first numeric value by the second.

Syntax:

{{#mod value1 value2}}

Parameters:

Returns: The remainder of the division as an integer.

Examples:

{{#mod 10 3}}                   {{!-- 1 --}}
{{#mod @index 2}}               {{!-- Current index % 2 --}}

abs

Calculates the absolute value of a numeric value.

Syntax:

{{#abs value}}

Parameters:

Returns: The absolute value of the input as an integer.

Examples:

{{#abs -5}}                     {{!-- 5 --}}
{{#abs 10}}                     {{!-- 10 --}}