Math filters allow you to apply mathematical tasks.
Math filters can be linked and, as with any other filters, are applied in order from left to right. In the example below, minus
is applied first, then times
, and finally divided_by
.
You save {{ rental.compare_at_price | minus: rental.price | times: 100.0 | divided_by: rental.compare_at_price }}%
Divides an output by a number. The output is rounded to the nearest integer.
<!-- rental.price = 200 -->
{{ rental.price | divided_by: 10 }}
20
Subtracts a number from an output.
<!-- rental.price = 200 -->
{{ rental.price | minus: 15 }}
185
Adds a number to an output.
<!-- rental.price = 200 -->
{{ rental.price | plus: 15 }}
215
Multiplies an output by a number.
<!-- rental.price = 200 -->
{{ rental.price | times: 1.15 }}
230
Divides an output by a number and returns the remainder.
{{ 12 | modulo:5 }}
2