Built-in filters
Last updated
Was this helpful?
Last updated
Was this helpful?
We will list the most useful filters here. You can find the complete list of filters in .
Adds the specified string to the end of another string.
Converts a timestamp into another date format. The format for this syntax is the same as . The input uses the same format as Ruby’s .
date
works on strings if they contain well-formatted dates
To get the current time, pass the special word "now"
(or "today"
) to date
.
Sets a default value for any variable with no assigned value. default
will show its value if the input is nil
, false
, or empty.
In this example, product_price
is not defined, so the default value is used.
In this example, product_price
is defined, so the default value is not used.
In this example, product_price
is empty, so the default value is used.
Divides a number by another number.
Subtracts a number from another number.
Inserts an HTML line break (<br />
) in front of each newline () in a string.
Adds a number to another number.
Multiplies a number by another number.
In this example, assume you have a list of products and you want to show your kitchen products separately. Using where
, you can create an array containing only the products that have a "type"
of "kitchen"
.
Take a look at the in_time_zone
filter .
Creates an array including only the objects with a given property value, or any value by default.