Mechanic include all filters available in Liquid's standard library. We also add a few of our own. :)

add_tag
add_tags
remove_tag
remove_tags

Use these filters to manipulate tag strings.

For background: Instead of working with tags as arrays, the Shopify API works with tags as comma-delimited strings; this makes it complicated to add or remove tags using only standard Liquid. These filters make it very simple.

{{ "a, b" | add_tag: "c" }}
=> a, b, c

{{ "a, b, e" | add_tags: "c", "d" }}
=> a, b, c, d, e

{{ "a, b, e" | add_tags: "c", "d", sort: false }}
=> a, b, e, c, d

{{ "a, b, c" | remove_tag: "b" }}
=> a, b

{{ "a, b, c" | remove_tags: "a", "c" }}
=> b

If supplied an array, these filters will return an array as well:

{{ "a,b,e" | split: "," | add_tags: "c", "d" | join: "-" }}
=> a-b-c-d-e

{{ "a,b,c,d,e" | split: "," | remove_tags: "c", "d" | join: "-" }}
=> a-b-e

unindent

Use this filter on strings to remove indentation from strings.

{% capture message %}
  Hello, friend!
  It's a mighty fine day!
{% endcapture %}

{{ message | unindent }}
Hello, friend!
It's a mighty fine day!
Did this answer your question?