Number Filters

divided_by

Divide a number by another.

Expects: Number

Argument Required Description
number required The number to divide the given number by
{{ 10 | divided_by: 2 }} # => 5

human_file_size

Converts a number of bytes into a human readable size.

Expects: Integer

{{ 1894302 | human_file_size }} # => 1.8 MB

minus

Subtract a number from another.

Expects: Number

Argument Required Description
number required The number to subtract from the given number
{{ 10 | minus: 2 }} # => 8

mod

Performs modular arithmetic.

Expects: Number

Argument Required Description
number required The number to mod given number by
{{ 18 | mod: 3 }} # => 0
{{ 19 | mod: 3 }} # => 1
{{ 20 | mod: 3 }} # => 2

plus

Adds a number or a string to another.

Expects: Number or String

Argument Required Description
number required The number or string to add to given number or string
{{ '1' | plus: '1' }} # => 11
{{ 1 | plus: 1 }} # => 2

times

Multiplies numbers, or repeats strings.

Expects: Number or String

Argument Required Description
number required The number to multiply the given number or string by
{{ 'foo' | times: 3 }} # => foofoofoo
{{ 5 | times: 3 }} # => 15

to_float

Turns a string into a floating point (decimal) number.

Expects: Number or String

{{ '4.5' | to_float }} # => 4.5

to_integer

Turns a string into an integer.

Expects: Number or String

{{ '4' | to_integer }} # => 4