Liquid tag list
This page contains a list of the liquid tags, variables, and filters available to you in Customer.io. Use the search bar below to look for a specific tag.
Our version of Liquid is currently 2.5.3
. If you can’t find an answer to your liquid-related question below, we also have our own syntax guide.
New to liquid? Check out our tutorial for marketers!
Looking for something specific?
Customer.io Tags
These are values generated by, or stored within, Customer.io. Reference these values to import information for a person. Many of the
.id
values are useful as UTM parameters in links, so you can log where your traffic is coming from or attribute customer actions to messages.campaign.id
“Your campaign’s numerical ID. This can be found in your campaign URL. For example, the campaign ID here is 2000:
https://fly.customer.io/env/12345/v2/campaigns/2000/overview.
For newsletters, your
campaign.id
is the value afternewsletters
in your URL. For example, the newsletter’scampaign.id
here is1
https://fly.customer.io/env/109950/composer/newsletters/1/templates/21
.”Syntax
{{campaign.id}}
campaign.name
The name that you assigned your campaign or newsletter. For example: “Q2 Anvil Onboarding Campaign [Coyotes]”.
Syntax
{{campaign.name}}
campaign.type
This returns whether or not your campaign is behavioral (segment triggered), transactional (event triggered), or a newsletter.
Syntax
{{campaign.type}}
content
Use in layouts to indicate where code added via the email editor will be included. You might use this in a template for a transactional message or API-triggered broadcast where you will provide content from the API directly.
Example
{{content}}
delivery_id
A URL-compatible base64 string that identifies an instance of a message created for a person. This is set to unsent in test send and composer previews, and generated when the message is drafted or sent.
Syntax
{{delivery_id}}
event_name
The name of the event that triggers a campaign.
Syntax
{{event_name}}
layout.id
The numerical ID associated with the email layout you’ve used.
Syntax
{{layout.id}}
layout.name
The name assigned to the email layout you’re using.
Syntax
{{layout.name}}
message.id
“The numerical ID for a message action in the workflow. For example, an SMS action might have a
{{message.id}}
of 200. Note that this identifies the action in your workflow, not the individual delivery instances. Every SMS delivery generated from the action would have a different{{delivery_id}}
.For newsletters, the
message.id
is the value after templates in your URL. For example, themessage.id
here is21
https://fly.customer.io/env/109950/composer/newsletters/1/templates/21
. "Syntax
{{message.id}}
message.journey_id
The ID for the path a person went through in a Campaign or API Triggered Broadcast workflow. You can use this value to trace message metrics back to a person’s path through a journey using the
journey.id
value sent in our Reporting Webhooks.Syntax
{{message.journey_id}}
message.name
The name you give your message in the workflow, like “Welcome to ACME!”
Syntax
{{message.name}}
message.preheader
For email messages only, if your message has a preheader value set, this tag echos it.
Syntax
{{message.preheader}}
message.subject
If your message has a subject, or the message subject is different from the message name, this tag echos it.
Syntax
{{message.subject}}
message.type
This refers to a particular message’s type. Possible values are:
email_action
,push_action
,twilio_action
,slack_action
,webhook_action
,urban_airship_action
,attribute_update_action
.Syntax
{{message.type}}
unsubscribe_url
Renders a unique unsubscribe link for a customer and their email-address.
Syntax
{% unsubscribe_url %}
view_in_browser_url
Our default link that generates a web version of your email, personalized for each recipient. In general, these URLs look something like:
http://e.customeriomail.com/deliveries/....
Syntax
{% view_in_browser_url %}
Variables and Assignment
There are common variables you can reference within messages and elsewhere. These may be variables associated with a person, the event triggering a message workflow, or variables that you assign within your message from other values.
assign
Assign a value to a variable.
Syntax
{% assign var_name = 'value' %}
Input
{% assign favorite_food = 'apples' %}
Output
{{ favorite_food }}
capture
Captures contents and assigns them to a variable.
Input
{% capture about_me %}I am 28 and my favorite food is pasta.{% endcapture %}
Output
{{ about_me }}
customer attributes
You reference customer attributes—data associated directly with a person in Customer.io—in the
customer
scope. You may want to use customer attributes with anif
conditional, so that you have text to fallback to if a customer doesn’t have the attribute in question.Syntax
{{customer.<attribute_name>}}
Example
{% if customer.name != blank %} Hi {{customer.name | capitalize}} {% else %} Hi Buddy {%endif%}
event properties
If you trigger a campaign using an event, you can reference properties from the event that triggers your campaign in the
event
scope. You may want to use event properties with anif
conditional, so that you have text to fallback to if an event doesn’t have the property in question or your property doesn’t contain the value you expect.Syntax
{{event.<property>}}
Example
{% if event.type == "purchase" %} Thanks for your purchase! {% else %} Thanks for using our service! {%endif%}
trigger properties
You can reference properties from the
data
object when you trigger a transactional message or API-trigger a broadcast using thetrigger
scope. This provides a convenient way to pass event data into transactional and broadcast templates. You may want to use trigger properties with anif
conditional, so that you have text to fallback to if your trigger data is incomplete or contains values you don’t expect.Syntax
{{trigger.<data.property>}}
Example
{% if trigger.first_name %} Hi {{trigger.first_name | capitalize}} {% else %} Hi Buddy {%endif%}
Logical Operators
Logical operators determine the basic rules for evaluating true or false statements. You can also use
and
andor
operators to combine logic statements to evaluate multiple conditions.and
Evaluate a statement as true when both conditions are true.
Syntax
{% if condition1 and condition2 %} // do something if both condition1 and condition 2 are true {% endif %}
Example
{% if customer.name == "bugs bunny" and event.episode_start == true %} What's up doc? {% else %} That's all folks! {% endif %}
Does not equal (!=)
Use
!=
to check that two values are not equal to each other.Example
{% if customer.name != "daffy duck" %} Duck season! {% else %} Wabbit season! {%endif%}
equals (==)
Use
==
to check if two values are equal to each other.Example
{% if customer.name == "daffy duck" %} Wabbit season! {% else %} Duck season! {%endif%}
Greater than and Greater than or equal to (>, >=)
Use
>
to match when one value is greater than another. Use>=
to match when one value is greater than or equal to another.Syntax
{% if val1 > val2 %} // do something if val1 is greater than val2 {% endif %}
Example
{% if customer.acct_age_years > 1 %} Thanks for being with us these past years {% else %} Thanks for spending the last year with us! {% endif %}
Less than and less than or equal to (<, <=)
Use
<
to match when one value is less than another. Use<=
to match when one value is less than or equal to another.Syntax
{% if val1 < val2 %} // do something if val1 is less than val2 {% endif %}
Example
{% if customer.purchases < 5 %} Thanks for your support {% else %} Thanks for spending the last year with us! {% endif %}
or
Evaluate a statement as true when either of two conditions are true.
Syntax
{% if condition1 or condition2 %} // do something if either condition1 and condition 2 are true {% endif %}
Example
{% if customer.name == "bugs bunny" or customer.group == "looney toons" %} That's all folks! {% else %} See you later! {% endif %}
Loops and Conditionals
Loop through an array of items or set conditions determining the content that you want to show.
case
Creates a set of conditions depending on a variable’s specific value—like a set of if, if-else, else conditions.
For example, you might use this to display different text depending on if a customer lives in a specific country.
Syntax
{% case condition %} {% when "value1" %} text when condition is value1. {% when "value2" or "value3" %} text when condition is value2 or value3 {% else %} text when condition does not match other conditions {% endcase %}
for loop
Repeatedly executes a block of code, most commonly to perform an operation for each item in an array. You might use a for loop in a message to provide a receipt of purchases (assuming an array of items in a purchase). Find more information about for loops and iteration here.
Syntax
{% for item in array %} {{ item }} {% endfor %}
Example
// You can output each item of the array {% for member in members_of_band %} {{member}} {% endfor %} // If the items are objects, you can output properties from each object {% for product in event.products %} - {{ product.title }} x {{ product.price }} {% endfor %}
if
Executes a block of code if a condition is met. Use
elsif
to add multiple ‘if’ conditions andelse
for the block of code you want to execute if all conditions are false. Find more information about conditional liquid here.Example
{% if customer.name == "chad" %} Hey Chad! {% elsif customer.name != "chad" %} Hey {{ customer.name | capitalize }}! {% else %} Hi Buddy! {% endif %}
unless
Like an if conditional, but reversed: this tag executes a block of code if your condition is not met.
Example
{% unless product.name == "cool beans" %} The beans are not cool. {% endunless %}
Timestamps and Dates
Use these tags to get and manipulate dates and times.
add_day
Adds a day, or multiple days, to a given timestamp.
Syntax
{{ <unix_timestamp> | add_day: <int_days> }}
Example
{{ 1477430251 | add_day: 7 }}
add_month
Adds a month, or multiple months, to a given timestamp.
Syntax
{{ <unix_timestamp> | add_month: <int_months> }}
Example
{{ 1477430251 | add_month: 7 }}
add_year
Adds a year, or multiple years, to a given timestamp.
Syntax
{{ <unix_timestamp> | add_year: <int_years> }}
Example
{{ 1477430251 | add_year: 4 }}
countdown
Creates a countdown timer in your message, helping you alert your audience to how soon an event they’re interested is set to happen. Countdown timers take several parameters. At the minimum, a countdown must include the font size, the foreground (font) color, the background color, and the time you want to count down to.
The countdown timer cannot contain more than 60 frames. This limits the size of the animated GIF in your messages. So, if the resolution is set to seconds, the counter will stop after 60 seconds from when the person opens their message. The countdown image reloads when a person opens the message again, so the counter will always be relevant to the user’s current time, but it cannot count indefinitely.
Parameter required format default description point ✓ integer The font size for the timer time ✓ ISO 8601 timestamp The date and time you want to countdown to in the format YYYY-MM-DD hh:mm:ss (TZ)
. Remember to close the time in quotes, as the value includes a space.fg ✓ hex color The foreground (font) hexidecimal color bg ✓ hex color The background hexidecimal color apng boolean false Determines whether to show your countdown as a gif (default) or animated PNG. Note that some browsers/email clients don’t support apng images. font string inter, roboto The font family for your timer weight string normal The font weight, takes normal CSS font-weight
values.locale language code en The language you want to display: en
(English),ru
(Russian),jp
(Japanese),zh
(Chinese),pt
(Portugese),es
(Spanish), andfr
(French)looping boolean false Determines whether the countdown timer should restart after it finishes resolution one of S, M, H, D S Determines how often the timer counts down—by the second, minute, hour, or day. frames integer 1 Number of seconds you want to show, based on the resolution, where seconds: 60, minutes: 2, hours: 1, days: 1 Example
{% countdown point:64 font:roboto weight:light fg:000000 bg:f2f6f9 time:"2022-07-04 12:00:00 (GMT)" locale:en looping:true resolution:S frames:2 %}
date
Format a date. Use the Ruby syntax reference for more information about date formatting syntax.
Input
{{ 1483272000 | date: '%H:%M, %a, %b %d, %Y'}}
Output
12:00, Sun, Jan 01, 2017
event_timestamp
The UNIX timestamp when a particular event was performed. This time is different from
now
!Syntax
{{event_timestamp}}
now
The current time in UTC. You must format time with
date
.To modify date or time with
add
orsubtract
filters you must convertnow
into a unix timestamp first usingdate: '%s'
. If you use our built inadd_day
,add_month
, oradd_year
filters, you must convert the timestamp to an integer first. You can do this by using theplus
filter to add0
as shown in the second example below.Example
{{ 'now' | date: '%I:%M %p %B %d, %Y' }} {{ 'now' | date: '%s' | plus: 0 | add_day: 1 | date: '%I:%M %p %B %d, %Y'}}
Output
08:28 AM May 11, 2021 08:28 AM May 12, 2021
subtract_day
Subtracts a day, or multiple days, to a given timestamp.
Syntax
{{ <unix_timestamp> | subtract_day: <int_days> }}
Example
{{ 1477430251 | subtract_day: 7 }}
subtract_month
Subtracts a month, or multiple months, to a given timestamp.
Syntax
{{ <unix_timestamp> | subtract_month: <int_months> }}
Example
{{ 1477430251 | subtract_month: 2 }}
subtract_year
Subtracts a year, or multiple years, to a given timestamp.
Syntax
{{ <unix_timestamp> | subtract_year: <int_years> }}
Example
{{ 1477430251 | subtract_year: 4 }}
timezone
Converts a timestamp to a timezone you specify. You can use
now
instead of a timestamp. Timezone inputs can be-3
(specify your number) or UTCExample
{{ 1483272000 | timezone: '-8' | date: '%H:%M, %a, %b %d, %Y'}}
Output
04:00, Sun, Jan 01, 2017
Array Filters
Liquid used to filter and manipulate arrays (lists of values). If your event or another incoming value is an array, you may iterate over the array with a
for
loop or grab items at a particular index of the array, to display information for your audience.compact
Removes
nil
(empty) values from an array.Input
{{ "mick, keith, nil, Charlie" | compact }}
Output
mick, keith, Charlie
concat
Concatenates arrays, joining them end to end. The resulting array contains all of the elements of both original arrays.
concat
does not remove duplicate entries unless you also use theuniq
filter.Input
{% assign stones = "mick, keith, ronnie, charlie" | split: ", " %} {% assign beatles = "john, paul, george, ringo" | split: ", " %} {% assign rolling_beatles = stones | concat: beatles %} {{ rolling_beatles | join: ", " }}
Output
mick, keith, ronnie, charlie, john, paul, george, ringo
cycle
In a ‘for’ loop, this tag loops through and outputs strings in the order they were passed.
Input
<ul> {% assign customer.characters = ["coyote","bugs","tweety"] %} {% for character in customer.characters %} <li class="{% cycle 'odd', 'even' %}">{{ character }}</li> {% endfor %} </ul>
Output
<ul> <li class='odd'>coyote</li> <li class='even'>bugs</li> <li class='odd'>tweety</li> </ul>
first
Returns the first element of the array.
Input
acme.characters = ["Wile E Coyote", "Road Runner"] {{ acme.characters | first }}
Output
Wile E Coyote
join
Joins the elements of an array with the character passed as the parameter.
Input
acme.characters = ["Wile E Coyote", "Road Runner"] {{ acme.characters | join: ', ' }}
Output
Wile E Coyote, Road Runner
last
Returns the last element of the array.
Input
acme.characters = ["Wile E Coyote", "Road Runner"] {{ acme.characters | last }}
Output
Road Runner
limit
Return a set number of values from an array or string.
Input
{% assign beatles = "john, paul, george, ringo" | split: ", " %} {{ beatles | limit: 2 | join: ", " }}
Output
john, paul
map
Creates an array of values by extracting the values of a property in an object. You can output your new characters in a ‘for’ loop.
Input
Array of objects: [{"name":"coyote"},{"name":"bugs"},{"name":"tweety"}]" {% assign names = customer.characters | map: 'name' %}
Output
coyote, bugs, tweety
remove
Remove an element from an array. The array can contain objects of any type.
Input
{% assign pl = collection.products | remove: collection.products[0] %} - {{ collection.products.size }} - {{ pl.size }}
Output
- 2 - 1
size
Returns the number of characters (the size) of a string (in characters) or the number of elements in an array.
Input
{{ "That's all, folks!" | size }}
Output
18
sort
Sorts the elements of an array by an attribute of an element in that array. Usually used with a ‘for’ loop. The order of the sorted array is case-sensitive!
Input
{% assign beatles = "paul, john, ringo, george" | split: ", " %} {{ beatles | sort | join: ", " }}
Output
george, john, paul, ringo
sort_natural
Sort the items in an array in case-insensitive order.
Input
{{ "mick, keith, Charlie, Ronnie" | sort_natural }}
Output
Charlie, keith, mick, Ronnie
uniq
Removes duplicate elements in an array.
Input
{% assign my_array = '"lions", "tigers", "bears", "bears", "lions"' %} {{ my_array | uniq | join: ", " }}
Output
lions, tigers, bears
where
Creates an array including only the objects with a given property value, or any “truthy” value by default. When using
where
, you provide two items separated by a comma: the key you want to match on and the value you want to match.Input
All Players: {% for player in collection.players %} - {{ player.last_name }} {% endfor %} Baseball Players: {% assign baseball_players = collection.players | where: "sport", "baseball" %} {% for player in baseball_players %} - {{ player.last_name }} {% endfor %}
Output
All Players: - Posey - Lincecum - Montana - Rice Baseball Players: - Posey - Lincecum
where_not
Creates an array of items that do not match a given property value, or any “falsey” value by default. When using
where_not
, you provide two items separated by a comma: the key you want to match on and the value you want to match.Input
All players: {% for player in collection.players %} - {{ player.last_name }} {% endfor %} Not baseball players: {% assign not_baseball_players = collection.players | where_not: "sport", "baseball" %} {% for player in not_baseball_players %} - {{ player.last_name }} {% endfor %}
Output
All players: - Posey - Maradona - Montana - Gretzky - Jordan Not baseball players: - Maradona - Montana - Gretzky - Jordan
Number and Currency Filters
These are tags and filters that manipulate incoming number, integer, and timestamp values.
Some tags, like the
currency
andformat_number
, take an optional localization parameter, formatting the output for a specific locale. These tags use the format{{ 10 | currency: "en-us" }}
, which would output$10.00
.We support the following localization values:
af, ar, az, be, bg, bn, bs, ca, cs, cy, da, de, de-AT, de-CH, de-DE, el, el-CY, en, en-AU, en-CA, en-GB, en-IE, en-IN, en-NZ, en-US, en-ZA, en-CY, en-TT, eo, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, gl, he, hi, hi-IN, hr, hu, id, is, it, it-CH, ja, ka, km, kn, ko, lb, lo, lt, lv, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or, pa, pl, pt, pt-BR, rm, ro, ru, sk, sl, sq, sr, st, sw, ta, te, th, tl, tr, tt, ug, ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE
abs
Returns the absolute value of a number.
Input
{{ 3.14 | abs }}
Output
3.14
ceil
Rounds a number up to the nearest integer.
Input
{{ 3.14 | ceil }}
Output
4
currency
Converts an integer to currency. This filter can also take an optional localization parameter to format currency for a specific locale.
Input
{{ 10 | currency }} {{ 123456.78 | currency: "fr" }}
Output
$10.00 123 456,78€
floor
Rounds a number down to the nearest integer.
Input
{{ 3.14 | floor }}
Output
3
format_number
Format a number with a delimiter. This filter also takes an optional localization parameter to format a number for a specific locale.
NOTE: This replaces the former
number_with_delimeter
filter.Input
{{ 10000 | format_number }} {{ 123456.78 | format_number: "fr" }}
Output
10,000 123 456,78
random
Generates a random number between 0 and an integer you specify.
Example
{% random 100 %}
round
Rounds a number up or down to the nearest integer, or to a decimal place you specify.
Input
{{ 4.32 | round }} {{ 4.32 | round: 1 }}
Output
4 4.3
rounded_currency
Rounds a number into the nearest whole integer and formats it to a currency. You cannot use the
locale
option with rounded_currency like you can with the standardcurrency
filter.Input
{{ 3.1415 | rounded_currency }}
Output
$3
to_json
Outputs the json representation of the input. For example,
{{ customer | to_json }}
sends all your customer data into a JSON variable.Example
{{ customer | to_json }}
Math Filters
Filters that perform math operations on incoming number or integer values.
at_least
Limits a number to a minimum value.
Input
{{ 41 | at_least: 42 }}
Output
42
at_most
Limits a number to a maximum value.
Input
{{ 100 | at_most: 99 }}
Output
99
divided_by
Divides a number by another number.
Input
{{ 10 | divided_by: 4 }} {{ 10 | divided_by: 4.0 }}
Output
2 2.5
minus
Subtracts a number from another number.
Input
{{ 10 | minus: 1 }}
Output
9
modulo
Returns the remainder of division.
Input
{{ 3 | modulo: 2 }}
Output
1
plus
Adds a number to another.
Input
{{ 10 | plus: 1 }}
Output
11
times
Multiplies a number by another number.
Input
{{ 5 | times: 2 }}
Output
10
String Filters
The following filters manipulate strings in templates. You might use these to truncate or set the case of strings you reference from other places, to humanize your messages for recipients.
append
Adds a string to the end of another string.
Input
{{ "What's all the hubbub, " | append: "bub?" }}
Output
What's all the hubbub, bub?
base64
Base64-encodes a string.
Input
{{ 'Hello, world!' | base64 }}
Output
SGVsbG8sIHdvcmxkIQ==
base64_decode
Decode a base64-encoded string.
Input
{{ "Zm9vLmJhcg==" | base64_decode }}
Output
foo.bar
base64_encode
Base64-encode a value.
Input
{{ "foo.bar" | base64_encode }}
Output
Zm9vLmJhcg==
base64_url_safe_decode
Decode a string from URL-safe Base64.
Input
{{ "Zm9vLmJhcg" | base64_url_safe_decode }}
Output
foo
base64_url_safe_encode
Encode a string into URL-safe Base64. To produce URL-safe Base64, this filter uses
-
and_
in place of+
and/
.Input
{{ "foo" | base64_url_safe_encode }}
Output
Zm9vLmJhcg
capitalize
Capitalize the first character in a string.
Input
{{ "hello world" | capitalize }}
Output
Hello world
contains
Finds a substring inside a string, or the presence of a string in an array of strings. This filter only works with strings; you cannot use it to search for an object in an array of object.
Syntax
{% if product.description contains 'lorem ipsum' %} You might also be interested in Fillerama or Office Ipsum. {% endif %}
downcase
Converts a string to lower case.
Syntax
{{ 'STRING' | downcase }}
Input
{{ "ACME" | downcase }}
Output
acme
escape
Escaping (or encoding) a string removes special characters.
Input
{{ "win+help@customer.io" | escape }}
escape_once
Escapes or encodes a string, but doesn’t include already-escaped characters.
Input
{{ "1 < 2 & 3" | escape_once }}
Output
1 < 2 & 3
hex_base64
Returns a base64 encoding of a hex digest, like ones returned by the
hmac_sha256
filter.Input
{{ "Customer.io" | hmac_sha256: "some_key" | hex_base64 }}
Output
bd23cyOCFrzicxM7w/ahKoJPQd0YTQlFLwXHZZ2ufVc=
hmac_sha1
Converts a string into an hmac_sha1 hash.
Input
{{ "Customer.io" | hmac_sha1: "some_key" }}
Output
2bdf556c9a75766f258d1e2824f6d0e31d1beedc
hmac_sha256
Converts a string into an hmac_sha256 hash.
Input
{{ "Customer.io" | hmac_sha256: "some_key" }}
Output
6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57
htmlencode
Escapes HTML characters into HTML entities.
lstrip
Strips all whitespace, including tabs, spaces, and newlines, from the left side of a string.
Input
text{{ " Customer.io " | lstrip }}text
Output
textCustomer.io text
md5
Converts a string into an md5 hash.
Input
{{ "Customer.io" | md5 }}
Output
d52b6a207bf5255c05b1d0056230617e
newline_to_br
Replaces newline with an HTML line break. input: See this example for output.
Input
<br /> Customer.io<br /> liquid<br />
pluralize
Outputs the singular or plural version of a string based on the value of a number. The first parameter is the singular string and the second parameter is the plural string.
Syntax
{{ int-val | pluralize 'singular', 'plural'}}
Input
{{ event.item_count | pluralize: 'item', 'items' }}
Output
3 items
prepend
Adds a string to the beginning of another string.
Input
{{ "Sufferin' succotash!" | prepend: "Sylvester: " }}
Output
Sylvester: Sufferin' succotash!
remove_first
Removes the first occurrence of a value from a string.
Input
{{ "folks that's all, folks!" | remove_first: "folks" }}
Output
that's all folks!
remove_last
Remove the last occurence of a string within a substring.
Input
{{ "foobarbar" | remove_last: "bar" }}
Output
foobar
remove
Removes a value from a string.
Input
{{ "And that's all, folks!" | remove: ", folks" }}
Output
And that's all!
replace
Find and replace values within a string. The first argument represents the value you want to replace, and the second argument is the replacement.
Syntax
{{ "String you want to replace values in" | replace: "find-str", "replace-str" }}
Input
{{ "Coyotes never catch roadrunners!" | replace: "never", "always" }}
Output
Coyotes always catch roadrunners!
replace_first
Find and replace the first match in a string. The first argument represents the value you want to replace, and the second argument is the replacement.
Syntax
{{ "String you want to replace values in" | replace_first: "find-str", "replace-str" }}
Input
{{ "roller rocket roller skates" | replace_first: "roller", "awesome" }}
Output
awesome rocket roller skates
replace_last
Replace the last occurence of a string within a substring.
Input
{{ "foobarbar" | replace_last: "bar", "foo" }}
Output
foobarfoo
rstrip
Strips all whitespace, including tabs, spaces, and newlines, from the right side of a string.
Input
text{{ " Customer.io " | rstrip }}text
Output
text Customer.iotext
sha1
Converts a string into a sha1 hash.
Input
{{ "Customer.io" | sha1 }}
Output
c197ff0ae0a41983362f35ca972c544061c54d4c
sha256
Converts a string into a sha256 hash.
Input
{{ "Customer.io" | sha256 }}
Output
6dddb773238216bce273133bc3f6a12a824f41dd184d09452f05c7659dae7d57
slice
Returns the character located at the index specified in the first argument. You can also provide a second argument indicating the length of the string you want to return (if you want to return multiple characters).
If the first argument is a negative number, the index is begins from the end of the string.
Syntax
{{ "string" | slice: <req, index of char>, <optional, length of result> }}
Input
{{ "Customer.io" | slice: 3 }} {{ "Customer.io" | slice: 3, 3 }} {{ "Customer.io" | slice: '-4', 3 }}
Output
t tom r.i
split
Divides an input string into an array using a separator you define. This filter is often used with a for loop.
Input
{% assign rolling_stones = "Mick, Keith, Ronnie, Charlie" | split: ", " %} {% for member in rolling_stones %} {{ member }} {% endfor %}
strip
Strips all whitespace, including tabs, spaces, and newlines, from the left and right side of a string.
Input
text{{ " Customer.io " | strip }}text
Output
Customer.io
strip_html
Removes HTML characters from a string.
Input
{{ "Eh, what's <i>up</i>, <b>Doc</b>?" | strip_html }}
Output
Eh, what's up, Doc?
strip_newlines
Removes line breaks (\n) from a string.
Example
{{ product.description | strip_newlines }}
titlecase
Converts a string to title case.
Syntax
{{ 'string' | titlecase }}
Input
{{ "rocket roller skates" | titlecase }}
Output
Rocket Roller Skates
truncate
Shortens a string to the specified number of characters, adding an ellipsis if the string is longer than the value provided.
Input
{{ "I knew I shoulda taken that left turn at Albuquerque." | truncate: 20 }}
Output
I knew I shoulda ...
truncatewords
Shortens a string to a specified number of words, rather than characters, and adds an ellipsis if the string contains more words than the value provided.
Input
{{ "I knew I shoulda taken that left turn at Albuquerque." | truncatewords: 8 }}
Output
I knew I shoulda taken that left turn...
upcase
Converts a string to upper case.
Syntax
{{ 'string' | upcase }}
Input
{{ 'acme' | upcase }}
Output
ACME
url_decode
Decodes a string that has been encoded as a URL or has been modified by
url_encode
.Input
{{ "%27Customer.io+is+great%27" | url_decode }}
Output
Customer.io is great
url_encode
Escapes/encodes URL-unsafe characters in a string.
Input
{{ "cool.person@example.com" | url_encode }}
Output
cool.person%40example.com
Miscellaneous
These are tags that you can use to escape liquid rendering or escape rendering all together.
comment
This tag doesn’t show its contents, providing a way for you to leave notes inside templates for other members of your organization.
Syntax
{% comment %} Don't display me! {% endcomment %}
generate_uuid
Generate a UUID.
Example
{% generate_uuid %}
raw
Temporarily disables Liquid processing. You might use this to escape tag processing if you use a conflicting syntax or you want to show raw liquid syntax in your message."
Example
{% raw %} {{This}} is displayed exactly as typed. {% endraw %}