Skip to main content

Is there a list of all the liquid filters that are supported in Freshworks products? The solution here only points to a Github repository of some of the filters that shopify has and even in this list not everything is supposed inside of Freshservice. 

 https://support.freshservice.com/en/support/solutions/articles/50000003382-powerful-placeholders-with-liquid-filters 

Link mentioned in article:https://shopify.github.io/liquid/basics/introduction/

I also noticed that some liquid filters don’t process correctly inside of an Expression node compared to a Action Node that adds a note. I stopped using liquid filters in Expression node after awhile due to having no way of knowing what syntax problem I am running into whether it is with the filter or Expression node itself. 

 

 

I want to bring this thread back to life as I am working on an email parser to get table data.  I am trying to get an HTML table from an email.  While you would think this is easy, it appears that the expression node transforms the HTML when you paste or access the data.  It is essentially manipulating the data before my eyes.

Anyone found a way around this behavior?



Hi Rawilkins,

We need further details to assist you with this query. We'll ask the support team to reach out and provide additional help.


Prasanth,  I don’t think its an issue with support.  I will chat with them on my weekly call on Tuesday, but this might be designed behavior so that you don’t allow scripting in the notes or description, but it is very frustrating trying to use a substring expression and get everything in-between table tags when they are parsed in the node.  What I am really looking for is consistent behavior, not one way when in the workflow editor, one way when the ticket is actioned, and a completely separate when testing the node. 


Thank you Dino for following up on this. 

I saw a ticket was support created for me and completely forgot about it since they labeled to source as phone. 

Prasanth, I will follow up with you via the ticket as well as provide my examples here when I find them again as this is from 4 months ago and need to refresh on what I went away from doing. 

 

 


I just submitted a very long update to this but seems it was sent into the being reviewed by moderators queue. If it doesn’t show up within a week or so I will have to format the post again or just attach a document instead. 


@rawilkins Do you have any updates on your findings?


@rawilkins Do you have any updates on your findings?

I did find some more of which ones work and which ones don’t. Since the community manager essentially ate my very large post I need to create it again. I was working on identify which word triggered a conditions  get matched from  “subject has any of these words” stuff so was side tracked. 
I was able to find some filters that worked that weren’t listed too. Such as 
 

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}}

{{% endraw %}}

 

Output:

{{ 2 | plus: 2 }}


Sorry everyone. I am trying to figure out where my posts are going to as they aren’t going through and say need to be reviewed by moderators. I do have a list from S through Z so far but need to redo it so it is easier to read what was used for the input and what the output from the action node into the notes looks like.


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!


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!

Well as I mentioned before that this is missing a lot of information than I once previously sent. So this particular set of information will seems confusing because it doesn’t state what is the input, what is the output, its referencing links and such…
I was in the process of rewritting it to include the liquid filters in code blocks and such to... It will be awhile until I can get the updated version out do to my work priorities. 
Whatever I @ mentioned Prasanth on 2 months ago is what was supposed to be posted, not the stuff I sent to you in a DM that contained only the bones of my last post.


@rawilkins Thank you for taking the time to do this, it will be hugely beneficial to the community. Not sure why it is being restricted but I am sure ​@Kamakshi V will get it sorted out.


Reply


OSZAR »