Posting this on behalf of @rawilkins @Prasanth Sampathkumar
Raw (Not listed on initial site but found on https://shopify.dev/docs/api/liquid/tags/raw )
Outputs any Liquid code as text instead of rendering it. **Can’t be used on itself**
Input
% raw %
2 | plus: 2 equals 4.
% endraw %
Output:
{% raw %}
{{ 2 | plus: 2 }} equals 4.
{% endraw %}
remove
Removes every occurrence of the specified substring from a string.
--Input
"I strained to see the train through the rain" | remove: "rain"
--Output
Result : {{ "I strained to see the train through the rain" | remove: "rain" }}
Expected Result: I sted to see the t through the
remove_first
Removes only the first occurrence of the specified substring from a string.
--Input
"I strained to see the train through the rain" | remove_first: "rain"
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
--Output
Result: {{ "I strained to see the train through the rain" | remove_first: "rain" }}
Expected Result: I sted to see the train through the rain
remove_last
Removes only the last occurrence of the specified substring from a string.
--Input
"I strained to see the train through the rain" | remove_last: "rain"
--Output
Result: {{ "I strained to see the train through the rain" | remove_last: "rain" }}
Expected Result: I strained to see the train through the
replace
Replaces every occurrence of the first argument in a string with the second argument.
Input
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
replace_first
Replaces only the first occurrence of the first argument in a string with the second argument.
Input
{{ "Take my protein pills and put my helmet on" | replace_first: "my", "your" }}
replace_last 5.2.0
Replaces only the last occurrence of the first argument in a string with the second argument.
Input
{{ "Take my protein pills and put my helmet on" | replace_last: "my", "your" }}
reverse
Reverses the order of the items in an array. reverse cannot reverse a string.
Input
assign my_array = "apples, oranges, peaches, plums" | split: ", "
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array | reverse | join: ", " }}
Although reverse cannot be used directly on a string, you can split a string into an array, reverse the array, and rejoin it by chaining together filters.
Input
"Ground control to Major Tom." | split: "" | reverse | join: ""
{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}
round
Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.
1.2 | round
{{ 1.2 | round }}
2.7 | round
{{ 2.7 | round }}
183.357 | round: 2
{{ 183.357 | round: 2 }}
rstrip
Removes all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words.
" So much room for activities " | rstrip !
{{ " So much room for activities " | rstrip }}!
size
Returns the number of characters in a string or the number of items in an array.
"Ground control to Major Tom." | size
{{ "Ground control to Major Tom." | size }}
assign my_array = "apples, oranges, peaches, plums" | split: ", "
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
{{ my_array.size }}
You can use size with dot notation when you need to use the filter inside a tag:
if site.pages.size > 10
{% if site.pages.size > 10 %}
This is a big website!
3: {% endif %}
slice
Returns a substring of one character or series of array items beginning at the index specified by the first argument. An optional second argument specifies the length of the substring or number of array items to be returned.
String or array indices are numbered starting from 0.
"Liquid" | slice: 0
{{ "Liquid" | slice: 0 }}
"Liquid" | slice: 2
{{ "Liquid" | slice: 2 }}
"Liquid" | slice: 2, 5
{{ "Liquid" | slice: 2, 5 }}
Here the input value is an array:
assign beatles = "John, Paul, George, Ringo" | split: ", "
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{{ beatles | slice: 1, 2 }}
If the first argument is a negative number, the indices are counted from the end of the string.
"Liquid" | slice: -3, 2
{{ "Liquid" | slice: -3, 2 }}
sort
Sorts items in an array in case-sensitive order.
assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", "
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
{{ my_array | sort | join: ", " }}
sort_natural
Sorts items in an array in case-insensitive order.
assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", "
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
{{ my_array | sort_natural | join: ", " }}
split
Divides a string into an array using the argument as a separator. split is commonly used to convert comma-separated items from a string to an array.
assign beatles = "John, Paul, George, Ringo" | split: ", "
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
{% for member in beatles %}
{{ member }}
{% endfor %}
strip
Removes all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
" So much room for activities "
{{ " So much room for activities " | strip }}!
strip_html
Removes any HTML tags from a string.
"Have you read Ulysses?"
{{ "Have you read Ulysses?" | strip_html }}
strip_newlines
Removes any newline characters (line breaks) from a string.
"Hello
there"
{% capture string_with_newlines %}
Hello
there
{% endcapture %}
{{ string_with_newlines | strip_newlines }}
times
Multiplies a number by another number.
3 | times: 2
{{ 3 | times: 2 }}
24 | times: 7
{{ 24 | times: 7 }}
183.357 | times: 12
{{ 183.357 | times: 12 }}
truncate
Shortens a string down to the number of characters passed as an argument. If the specified number of characters is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.
"Ground control to Major Tom." | truncate: 20
{{ "Ground control to Major Tom." | truncate: 20 }}
truncatewords
Shortens a string down to the number of words passed as an argument. If the specified number of words is less than the number of words in the string, an ellipsis (…) is appended to the string.
"Ground control to Major Tom." | truncatewords: 3
{{ "Ground control to Major Tom." | truncatewords: 3 }}
uniq
Removes any duplicate items in an array. assign my_array = "ants, bugs, bees, bugs, ants" | split: ", "
{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}
{{ my_array | uniq | join: ", " }}
upcase
Makes each character in a string uppercase. It has no effect on strings which are already all uppercase."
"Parker Moore" | upcase
{{ "Parker Moore" | upcase }}
url_decode
Decodes a string that has been encoded as a URL or by url_encode.
"%27Stop%21%27+said+Fred" | url_decode
{{ "%27Stop%21%27+said+Fred" | url_decode }}
url_encode
Converts any URL-unsafe characters in a string into percent-encoded characters."
"[email protected]" | url_encode
{{ "[email protected]" | url_encode }}
@rawilkins - Please feel free to quote this and add in your message!