Filters #
Filters transform a variable value. Chain multiple filters with |:
{{ title | truncate: 30 | upcase }}
| Syntax | Description · Example |
|---|---|
{{ title | upcase }} |
Converts to uppercase."sale" → "SALE" |
{{ title | downcase }} |
Converts to lowercase."SALE" → "sale" |
{{ title | capitalize }} |
Uppercases the first character and lowercases the rest."hELLO" → "Hello" |
{{ title | strip }} |
Removes leading and trailing whitespace." hi " → "hi" |
{{ title | prepend: "prefix" }} |
Adds a string before the value."world" → "prefixworld" |
{{ title | append: "suffix" }} |
Adds a string after the value."hello" → "hellosuffix" |
{{ title | replace: "and", "&" }} |
Replaces every occurrence of the first argument with the second."a and b" → "a & b" |
{{ title | split: " - " | first | strip }} |
split divides text into parts using the specified separator. It is commonly combined with first, last, or join.Title: Organic Cotton Throw - Sand BeigeResult: Organic Cotton Throw |
{{ title | slice: 0, 7 }} |
slice extracts part of a text value. The first number is the starting position and the second is the number of characters to return. Title: Vintage Denim JacketResult: Vintage |
{{ title | split: " / " | first | strip }} |
first returns the first item from a list, for example after using split.Title: Navy / Cream / RustResult: Navy |
{{ title | split: " - " | last | strip }} |
last returns the last item from a list, for example after using split.Title: Minimalist Pendant Necklace - Brushed SilverResult: Brushed Silver |
{{ title | split: " / " | join: " + " }} |
join combines the items in a list using the specified separator. Title: Cotton / Linen / ModalResult: Cotton + Linen + Modal |
{{ title | truncate: 30 }} |
Truncates to N characters total. The ellipsis (...) counts toward the limit."Hello World" | truncate: 8 → "Hello..." |
{{ title | truncate: 30, "…" }} |
Truncates with a custom ellipsis string."Hello World" | truncate: 8, "…" → "Hello W…" |
{{ title | truncatewords: 3 }} |
Truncates to at most N words."one two three four" | truncatewords: 2 → "one two..." |
{{ title | default: "fallback" }} |
Returns the fallback value when the variable is empty or undefined."" | default: "N/A" → "N/A" |
{{ price | round }} |
Rounds to the nearest integer. Non-numeric input is returned unchanged."3.7" → "4" |
{{ price | round: 2 }} |
Rounds to N decimal places."3.14159" | round: 2 → "3.14" |
{{ price | ceil }} |
Rounds up to the nearest integer."4.1" → "5" |
{{ price | floor }} |
Rounds down to the nearest integer."4.9" → "4" |
Combine filters #
You can chain multiple filters together to extract and format exactly the part of a variable you want to display.
For example:
{{ title | split: " - " | last | strip }}
With the title:
Classic Canvas Backpack - Olive Green
The result is:
Olive Green
Product tags and conditional logic #
Image Template text layers support the tags variable together with the contains operator and Liquid conditional statements such as if, elsif, and else. You can use them to display different text depending on a product's Shopify tags.
Display text for products with a specific tag #
For example, display a "BESTSELLER" label only for products tagged bestseller:
{% if tags contains "bestseller" %}BESTSELLER{% endif %}
If the product has the tag bestseller, the text layer displays BESTSELLER. Otherwise, no text is displayed.
Use elsif to display one of several values #
Use elsif when you want to check several conditions but display only the first matching result.
For example, a clothing merchant might want to highlight the material of each product, such as Organic Cotton, Linen, Recycled Polyester, or Merino Wool, without creating a separate Image Template for each material.
Add the following Liquid code to a text layer:
{% if tags contains "Organic Cotton" %}Organic Cotton
{% elsif tags contains "Linen" %}Linen
{% elsif tags contains "Recycled Polyester" %}Recycled Polyester
{% elsif tags contains "Merino Wool" %}Merino Wool
{% else %}Premium Material
{% endif %}
Flexify checks the conditions from top to bottom and displays the text for the first matching condition. Once a condition matches, the remaining elsif conditions are skipped.
If none of the specified tags are present, the optional else condition displays Premium Material.
This allows merchants to use a single Image Template across their product catalog while automatically displaying the most relevant text for each product.
Tip: Use separate
ifstatements when you want multiple matching values to appear. Use anif/elsifchain when only one result should be displayed.