Filters are how you can alter the outcome of numbers, strings, variables, and objects in Liquid. They empower you to reshape static and dynamic text, like transforming a string from lowercase to uppercase or conducting mathematical operations such as addition or division.

Filters must be placed within an output tag {{ }} and are denoted by a pipe character |.

The table below lists the Liquid filters that Naxai currently supports.

As filters generally modify an output, most must be in double curly braces.

Math Filters

FilterDescription
absReturns the absolute value of a number.
at_leastLimits a number to a minimum value.
at_mostLimits a number to a maximum value.
ceilRounds an input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
divided_byDivides a number by another number. The result is rounded down to the nearest integer (that is the floor) if the divisor is an integer.
floorRounds an input down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
minusSubtracts a number from another number.
moduloReturns the remainder of a division operation.
plusAdds a number to another number.
roundRounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.
timesMultiplies a number by another number.

📘

Controlling rounding

divided_by produces a result of the same type as the divisor — that is, if you divide by an integer, the result will be an integer. If you divide by a float (a number with a decimal in it), the result will be a float.

String Filters

FilterDescription
appendAdds the specified string to the end of another string.
capitalizeMakes the first character of a string capitalized and converts the remaining characters to lowercase.
downcaseMakes each character in a string lowercase. It has no effect on strings which are already all lowercase.
escapeEscapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn’t change strings that don’t have anything to escape.
lstripRemoves all whitespace (tabs, spaces, and newlines) from the left side of a string. It does not affect spaces between words.
newline_to_brInserts an HTML line break (<br />) in front of each newline (\n) in a string.
prependAdds the specified string to the beginning of another string.
removeRemoves every occurrence of the specified substring from a string.
remove_firstRemoves only the first occurrence of the specified substring from a string.
replaceReplaces every occurrence of the first argument in a string with the second argument.
replace_firstReplaces only the first occurrence of the first argument in a string with the second argument.
rstripRemoves all whitespace (tabs, spaces, and newlines) from the right side of a string. It does not affect spaces between words.
sizeReturns the number of characters in a string or the number of items in an array.
splitDivides 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.
stripRemoves all whitespace (tabs, spaces, and newlines) from both the left and right sides of a string. It does not affect spaces between words.
strip_htmlRemoves any HTML tags from a string.
strip_newlinesRemoves any newline characters (line breaks) from a string.
truncateShortens 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.
truncatewordsShortens 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.
upcaseMakes each character in a string uppercase. It has no effect on strings which are already all uppercase.
url_decodeDecodes a string that has been encoded as a URL or by url_encode.
url_encodeConverts any URL-unsafe characters in a string into percent-encoded characters.

Array Filters

FilterDescription
compactRemoves any nil values from an array.
concatConcatenates (joins together) multiple arrays. The resulting array contains all the items from the input arrays.
firstReturns the first item of an array.
joinCombines the items in an array into a single string using the argument as a separator.
lastReturns the last item of an array.
mapCreates an array of values by extracting the values of a named property from another object.
reverseReverses the order of the items in an array. reverse cannot reverse a string.
sizeReturns the number of characters in a string or the number of items in an array.
sliceReturns a substring of one character or series of array items beginning at the index specified by the first argument.
sortSorts items in an array in case-sensitive order.
sort_naturalSorts items in an array in case-insensitive order.
splitDivides 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.
sumSums all items in an array.
uniqRemoves any duplicate items in an array.
whereCreates an array including only the objects with a given property value, or any truthy value by default.

Date Filter

The date filter can convert a timestamp into a different date format. You can pass in parameters to the date filter to reformat the timestamp. For examples of these parameters, refer to strfti.me .

This page was last updated at {{ "now" | date: "%Y-%m-%d %H:%M" }}.
This page was last updated at 2023-07-07 14:07.
{% assign currentDay = "now" | date: "%A" %}  
{% if currentDay == "Friday" %}  
Have a great weekend!  
{% endif %}

Default Filter

Default values can be added by specifying a Liquid Filter (use | to distinguish the filter inline) with the name “default.”

If a default value is not provided and the field is missing or not set on the user, the field will be blank in the message.

Hi {{ contact.firstName | default: "Valued Customer" }}, thanks for using our product!