Number Filters

Number Filters

Use number filters to convert, manipulate, and display numbers.

abs

Returns the absolute value of a number.

abs

{{"-2" | abs}}
2

at_least

Limits a number to a minimum value

at_least: number

{{-1 | at_least:5}}
5

at_most

Limits a number to a maximum value

at_most: number

{{-1 | at_most:16}}
-1

ceil

Returns the next integer value greater than or equal to the current value.

ceil: integer

{{3.2 | ceil}}
4

divided_by

Divide the current value by operand.

divided_by: object operand

{{8 | divided_by:2}}
4

floor

Returns the next integer value less than or equal to the current value.

floor: integer

{{5.9 | floor}}
5

minus

Subtracts the operand from the current value.

minus: object operand

{{5 | minus:1}}
4

modulo

Return the remainder of the current value when divided by the operand.

modulo: object operand

{{12 | modulo:5}}
2

plus

Adds the operand to the current value. Note that this filter behaves differently if the current value is a string.

plus: object operand

{{3 | plus:5}}
8

rand

Returns a random integer between 0 and the current integer.

rand

{{10 | rand}}
8

round

Rounds a decimal value to the specified number of places.

round: integer places = 0

{{9.89| round}}
10

times

Multiply the current value by the operand. Note that this filter behaves differently if the current value is a string and the operand is an integer.

times: object operand

{{2| times:7}}
14

to_int

Converts the input into an integer. Useful when grabbing query parameters or other string inputs.

to_int

{{"2"| to_int}}
2

to_int

Converts the input into a number, which could be an integer or a fractional number.

to_number

{{"2.2"| to_number}}
2.2