Filters
Data can be filtered, or modified, before being output. These filters might be simple, or might take one or more arguments to modify their operation.
For example, to output a string in uppercase (no matter of the casing of the original value):
I am going to yell my name: "{{ "Deane" | upcase }}!!!"
I am going to yell my name: "DEANE!!!"
That filter took no arguments. A more complex filter can take an argument:
The amount is {{ amount | format_number:"N0" }}.
Other filters might take multiple arguments in a specific order (meaning, the backing function is accessing them by positional index):
Published: {{ article.date_published | format_date:"MMMM dd, yyyy", "en-us" }}
Other filters might use named arguments (this example is fictional, because this is rare in the built-in filters):
My name is {{ name | yell: volume:10 }}
(Again, it’s rare to use named arguments. The built-in filters only used them once, for an argument that is very rarely used for its filter.)
Finally, filters can be chained or “piped.” A filter returns a FluidValue
(we’ll talk about these later) which can be passed to another filter:
Title: "{{ title | strip | upcase | remove_first:"-" }}"
There are a couple dozen built-in filters. Most of the Liquid filters have been ported to Fluid. There are in several groups:
(Note: the color filters are available in the code, but not loaded by default.)
You can define your own filters (see Custom Filters).
A non-existent filter won’t throw an error, it just won’t affect the output at all – it will simply pass through the value supplied to the non-existent filter.