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.
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
bob
upcase
Converts the object contents to upper case.
Input
{{ 'bob' | upcase }}
Output
BOB
capitalize
Capitalizes the first letter of the first word in a string.
Input
{{ 'a string of text' | capitalize }}
Output
A string of text
split
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 -->
Doe
timestamp
Converts date and time to UNIX time (the number of seconds since 1970) in order to do calculations.
Input
{{ subscriber.signup_date | timestamp }}
Output
1492708640
date
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 PM
in_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 -0700
advance_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 +0000
at_midnight
Resets the time to midnight for a specific day.
Input
{{ now | at_midnight }}
Output
2017-04-21 00:00:00 +0000
strip_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 string
plus
Adds a value to a number.
Input
<!-- subscriber.lifetime_value = 10 --> {{ subscriber.lifetime_value | plus: 5 }}
Output
15
minus
Substracts a value from a number.
Input
<!-- subscriber.lifetime_value = 10 --> {{ subscriber.lifetime_value | minus: 5 }}
Output
5
times
Multiplies a number by the specified value.
Input
<!-- subscriber.lifetime_value = 10 --> {{ subscriber.lifetime_value | times: 2 }}
Output
20
divided_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
2
modulo
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 --> 1
round
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.87
ceil
Rounds the input up to the nearest integer.
Input
{{ 25.367 | ceil }}
Output
26
floor
Rounds the input down to the nearest integer.
Input
{{ 75.873 | floor }}
Output
75
cents
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.00
Drip’s Liquid money filters are not the same as Shopify’s Liquid money filter. Drip does not support the Shopify money filters.