Filters are a means of formatting or performing operations on your object data. They are included in an output tag {{ }} and begin with a pipe character |. Filters can be used in combination, reading from left to right, to perform multiple actions on an object.
Just to note: Testing what renders with liquid can be done by Previewing the email.
default
Specifies some optional default value to be inserted when computed Liquid results in a nil value or an empty string "".
Input
Hey {{ subscriber.first_name | default: "there" }}!Output
<!-- If subscriber.first_name is nil -->
Hey there!
<!-- If subscriber.first_name is "Bob" -->
Hey Bob!downcase
Converts the object contents to lower case.
Input
{{ 'Bob' | downcase }}Output
bobupcase
Converts the object contents to upper case.
Input
{{ 'bob' | upcase }}Output
BOBcapitalize
Capitalizes the first letter of the first word in a string.
Input
{{ 'a string of text' | capitalize }}Output
A string of textsplit
Divides a string into an array using the argument as a separator.
Input
{{ subscriber.full_name | split: ' ' | first }}
{{ subscriber.full_name | split: ' ' | last }}Output
<!-- If subscriber.full_name is John Doe -->
John
<!-- If subscriber.full_name is John Doe -->
Doetimestamp
Converts date and time to UNIX time (the number of seconds since 1970) in order to do calculations.
Input
{{ subscriber.signup_date | timestamp }}Output
1492708640date
Used with the {{ now }} object to specify the date and time format to be displayed.
Input
{{ now | date: "%a, %B %d, %Y at %I:%M %p" }}Output
Thu, April 20, 2017 at 07:15 PMin_time_zone
Converts a non-UNIX time to the specific time zone. Click here to see examples of common time zone strings, or click here to view the full database of worldwide time zones.
Input
{{ now | in_time_zone: "America/Los_Angeles" }}Output
2017-04-20 12:15:34 -0700advance_date_to_next
Advances a date to a specific day in the next 7 days.
Input
<!-- subscriber.created_at = 2017-04-20 20:48:12 +0000-->
{{ subscriber.created_at | advance_date_to_next: "Friday" }}Output
2017-04-21 20:48:12 +0000at_midnight
Resets the time to midnight for a specific day.
Input
{{ now | at_midnight }}Output
2017-04-21 00:00:00 +0000strip_commas
Removes commas from any string. Useful in situations when you might be unable to control the string used to create a tag (tags should not contain a comma, since several places in Drip store tags as comma-delimited lists). Examples include creating a tag by using a property of a custom event or from an integration that pushes purchase information into Drip.
Input
{{ "this is, my string" | strip_commas }}Output
this is my stringplus
Adds a value to a number.
Input
<!-- subscriber.lifetime_value = 10 -->
{{ subscriber.lifetime_value | plus: 5 }}Output
15minus
Substracts a value from a number.
Input
<!-- subscriber.lifetime_value = 10 -->
{{ subscriber.lifetime_value | minus: 5 }}Output
5times
Multiplies a number by the specified value.
Input
<!-- subscriber.lifetime_value = 10 -->
{{ subscriber.lifetime_value | times: 2 }}Output
20divided_by
Divides a number by specified value. The divided_by filter produces a result of the same type as the divisor — if you divide by an integer, the result will be an integer. If you divide by a number with a decimal in it, the result will be a number with a decimal in it.
Input
<!-- subscriber.lifetime_value = 10 -->
{{ subscriber.lifetime_value | divided_by: 5 }}Output
2modulo
Divides a number by a specified value and outputs the remainder, if any. This can be used to randomly split a list into “even” and “odd” groups for split testing.
Input
{{ subscriber.signup_date | timestamp | modulo: 2 }}Output
<!-- Input is an even number -->
0
<!-- Input is an odd number -->
1round
Mathematically rounds the input to the nearest integer or specified decimal place.
Input
<!-- subscriber.average_purchase = 47.87432 -->
{{ subscriber.average_purchase | round: 2 }}Output
47.87ceil
Rounds the input up to the nearest integer.
Input
{{ 25.367 | ceil }}Output
26floor
Rounds the input down to the nearest integer.
Input
{{ 75.873 | floor }}Output
75cents
Cents filter modify the variable, a monetary value to appear in a dollar amount. Any currency can be appended to a value and is not limited to European or American dollars.
Input
${{ 100 | cents }}€{{ 100 | cents }}Output
$1.00€1.00
dollars
Dollars filter modify the variable, a monetary value to appear with two decimal points after the value. Any currency can be appended to a value and is not limited to European or American dollars.
Input
${{ 100 | dollars }}€{{ 100 | euros }}Output
$100.00€100.00Drip’s Liquid money filters are not the same as Shopify’s Liquid money filter. Drip does not support the Shopify money filters.