Skip navigation

Filters

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

timestamp

Converts a 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. Click here for a list of commonly used placeholders to format the output, or view the Ruby documentation for less commonly used placeholders.

Input

{{ now | date: "%a, %B %d, %Y at %I:%M %p" }}

Output

Thu, April 20, 2017 at 07:15 PM
ValueDescription of returned value
%YYear with century, padded to at least 4 digits.
%yYear without century (00..99)
%mMonth of the year, zero-padded (01..12)
%-mMonth of the year, no-padded (1..12)
%BThe full month name (January)
%bThe abbreviated month name (Jan)
%dDay of the month, zero-padded (01..31)
%eDay of the month, no-padded (1..31)
%HHour of the day, 24-hour clock, zero-padded (00..23)
%kHour of the day, 24-hour clock, blank-padded ( 0..23)
%IHour of the day, 12-hour clock, zero-padded (01..12)
%lHour of the day, 12-hour clock, blank-padded ( 1..12)
%PMeridian indicator, lowercase (am/pm)
%pMeridian indicator, uppercase (AM/PM)
%MMinute of the hour (00..59)
%SSecond of the minute (00..60)
%zTime zone as hour and minute offset from UTC (+0900)
%AThe full weekday name (Sunday)
%aThe abbreviated name (Sun)
%uDay of the week (Monday is 1, 1..7)
%wDay of the week (Sunday is 0, 0..6)

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
TimezoneUTC Offset
America/New_York-0500
America/Chicago-0600
America/Denver-0700
America/Los_Angeles-0800
Europe/London+0000
Europe/Paris+0100
Europe/Moscow+0300
Asia/Hong_Kong+0900
Asia/Tokyo+0900

This is just a small sampling of available time zone strings. Click here to view the full database.

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 specified value.

Input

<!-- subscriber.lifetime_value = 10 -->
{{ subscriber.lifetime_value | times: 2 }}

Output

20

divided_by

Divides a number by specified value.

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
Previous: Attributes Next: Tags