Intermediate Filters
Alex Patton on Nov 3, 2021
Just got here? This module is part of a full-length Liquid tutorial. Start from the beginning.
In this module, we’ll cover types of filters and how they work with different kinds of values:
- String filters
- Math filters
- Number and currency filters
- Array filters
Earlier, you learned that filters change how the values of keys are displayed in emails. We experimented with the capitalize and strip filters to clean up our salutation so it looked just right. In this module, we’ll dive more deeply into filters and the myriad ways you can use them in conjunction with your keys.
Let’s start out with a quick reminder of what filter notation looks like in Liquid. You place the filter after the key and use a pipe character to separate them:
{{ customer.first_name | capitalize }}
Hi Lee
Remember, whatever platform you’re using will have its own flavor of Liquid, which could include different kinds of filters. Here are a few common filters you might encounter, just to give you an idea:
- capitalize capitalizes the first letter of the value
- upcase capitalizes all the letters of the value
- font_face changes the font that your value is displayed in
- link to generates an HTML link in the text
- format_number changes how a number value is displayed, such as adding a comma to numbers with more than three digits (aka, “4,000” instead of “4000”)
Those are some fairly simple examples; there are many, many more types of filters, some of which can get complex—especially when you use multiple filters at once!
Though there are lots of filters, they generally fall into four common types, which you can use to affect different kinds of values in various ways.
Up Next: Intermediate Filters – String Filters