- 31 Mar 2025
- 2 minute read
- Print
- DarkLight
- PDF
Liquid Markup Filters
- Updated 31 Mar 2025
- 2 minute read
- Print
- DarkLight
- PDF
Filters in Liquid Markup allow for the transformation of data before it’s displayed. This can be useful for modifying the returned value of merge fields/exports without making adjustments to the underlying query.
How Filters Work
Filters are added to the export that you’re looking to adjust. The filter is placed after the export you wish to modify, preceded by a pipe delimiter (‘|’). The filter then takes that export and transforms it accordingly.
Example
If you have a string of text like “Hello User,” and you wish to make it all uppercase. You could use the upcase filter.
{{"Hello User" | upcase}}
which would output
HELLO USER
Example
If you have an export such as {{academic-intererests}}, and you wish to make it all lowercase. You could use the downcase filter.
{{academic-interests | downcase}}
This would display any value in the academic-interests export entirely lowercase - so Biology would be displayed as biology etc.
Chaining Filters
You can chain filters together to perform several actions in a row on the same export. Each filter processes the output rendered by the previous filter in order to display the relevant information. In other words, filters work from left to right.
{{academic-interests | downcase | truncate: 10}}
This example above would display any academic-interest in lowercase, then would shorten each academic interest to a string of 10 characters. So a program like Environmental Sciences would display as environmen.
Filters
Standard Filters | Function | Example(s) |
---|---|---|
date | Formats a date | {{form-date | date: 'MMMM d, yyyy' }} |
divided_by | Divides two numbers | {{registration_limit | divided_by: registrants }} |
downcase | Sets all letters to lowercase | {{first | downcase }} |
first | Returns the first element of an array | {{academic_interests | first }} |
last | Returns the last element of an array | {{academic_interests | last }} |
map | Returns only the specified elements in an array | {{scholarships | map: 'names'}} |
minus | Subtracts two numbers | {{registration_limit | minus: registrants }} |
modulo | Returns the remainder after division | {{4 | modulo: 2 }} |
plus | Adds two numbers | {{registrants | plus: waitlist }} |
replace_first | Replaces the first occurrence of a match | {{sisID | replace_first:'Slate-', '' }} |
size | Returns the number of elements in an array or the number of characters in a string | {{academic_interests | size}} {{academic_interests.size}} |
slice | Extracts a part of a string, starting from a specific position and can grab an optional length | {{ sports | slice: 3,4}} |
snippet | Allow you to pass in a value and output a content block. | {{ program | snippet: "program_long_description" }} |
split | Splits a string into an array on a matching criteria | {{ academic_interests | split: "|" }} |
strip_html | Removes HTML tags from a string | {{ academic_interests | strip_html }} |
times | Multiples two numbers | {{courses | times: 550 }} |
truncate | Cuts the string down to the number of characters specified. | {{academic-interest | truncate: 5}} |
uniq | Dedupes values in an array | {{ academic_interests_array | uniq }} |
upcase | Sets all letters to uppercase | {{ first | upcase }} |