Filters may be used to modify the output of objects before either being stored in a variable or output to the page. Filters should be used as "expression | filter_name:filterParam1, filterParam2, etc..." (eg: {{ request.date | inspect: 2, true }}, or {% assign end_date = request.date | add_weeks:1 %}).
Multiple filters may be applied to an object at the same time and are processed in the same order that they appear in the markup. Eg: {% assign my_date = request.date | midnight | add_hours:3 %} will result in a different date than {% assign my_date = request.date | add_hours:3 | midnight %}
Adds the operand to the current value. Note that this filter behaves differently if the current value is a string
plus: Number operand
Add some numbers together
CopyMultiply the input by the operand.
times: Number operand
Use the times filter to multiply a number by another number
You can currently use the times to multiply a string into a list of identical strings, although this behavior is deprecated. If you need this functionality you are advised to find a different way to accomplish it.
Using the times filter with a string
CopyCurrent functionality
Future functionality
Potential Replacement
Alternate Replacement
Divide the input by operand.
divided_by: Number operand
Use the divided_by filter to divide one number by another.
Return the remainder of the input when divided by the operand.
modulo: Number operand
Use the modulo filter to get the remainder when one number is divided by another.
Using the modulo filter
CopySubtracts the operand from the input.
minus: Number operand
Use the minus filter to subtract one number from another.
Converts the input to an integer.
to_int
Convert a query parameter to an integer value with a default value.
Convert to integer
CopyConverts the input to a number.
to_number
Convert a query parameter to a number with a default value.
Convert to number
CopyAdd text to the end of the input. If the input is not already a string it will be converted to one using the default behavior for its object type.
append: String text
Append text onto the end of a string
Append text
CopyCapitalize words in a string
capitalize
Capitalize all of the words in a sentance
Capitalize words in a string
CopyRemoves all non-alphanumeric characters other than dashes and underscores from a string and replaces them with the separator (or nothing if the separator is empty) to form a valid CSS classname.
classname: String separator
Three ways to use the classname filter to convert text into a valid CSS classname
Convert text to a classname
CopyConvert a string to lowercase
downcase
Convert all characters in a string to lowercase.
Convert a string to lowercase
CopyEncode a string to be output as HTML. All special HTML characters will be converted to their equivalent HTML character entities (eg: < becomes <)
escape
Escape HTML characters in a string for output inside other HTML markup.
Escape HTML characters in a string
CopyA string with HTML & other characters
" | escape}}">...Encode a string to be output as HTML, without changing existing escaped entities.
escape_once
Escape HTML characters in a string for output inside other HTML markup. If HTML characters have already been escaped, do not "double-escape" them.
Escape HTML characters in a string once
Copy...
Use the json_encode filter instead.
Encode a string to be used output as JSON. Unlike json_encode, if the string is null this will return an empty string instead.
for_json
Use the for_json filter on variables that both do and do not have values
For Json Deprecation
CopyAlias for escape, which encodes a string to be output as HTML. Although h is shorter, escape is preferred due to its improved readability and maintainability.
h
Decodes any encoded HTML entities (eg: < becomes <)
html_decode
Decode any encoded HTML entities inside a string.
Decode HTML entities in a string
CopyEncode a string to be output as HTML. All special HTML characters will be converted to their equivalent HTML character entities (eg: < becomes <). This is functionally identical to the escape filter, though it may be more intuitive in some contexts - such as when using both the html_encode and html_decode filters to execute more advanced string manipulation.
html_encode
Encode a string for output inside other HTML markup.
Encode HTML entities in a string
CopyA string with HTML & other characters
" | html_encode}}">...Returns the 0-based location of the find string in the current string, or -1 if it cannot be found. If start is greater than 0, the search will begin at the specified index. To ignore capitalization, set ignorecase to true.
index: String findInteger startBoolean ignorecase
Multiple ways to use the index filter to search for text inside a string.
Get Substring Indexes with Various Arguments
CopyDecode a json encoded string
json_decode
Use the json_decode filter to decode a json encoded string
Decode a json encoded string
CopyEncode the input object to be used as a JSON property.
json_encode
Use the json_encode filter to format the input for output as json properties. While most usefulf or strings, this can also be used with other object types.
Json_encode various object types
CopyReturns the last 0-based location of the last occurrence of find string in the current string, or -1 if it cannot be found. If start is greater than or equal to 0, the search will begin at the specified index. To ignore capitalization, set ignorecase to true.
last_index: String findInteger startBoolean ignorecase
Multiple ways to use the last_index filter to search for text inside a string.
Getting the last substring indexes with various arguments
CopyRemoves whitespace from the beginning of a string
lstrip
3 filters to remove whitespace from before and after strings
Various ways to strip whitespace from strings
CopyAdd <br /> tags in front of all newlines in the current string
newline_to_br
Add <br /> in front of all newlines in a string
CopyAdds the operand to the current value. Note that this filter behaves differently if the current value is a string
plus: Number operand
Add some numbers together
CopyAdd text to the beginning of the input. If the input is not already a string it will be converted to one using the default behavior for its object type.
prepend: String text
Prepend text onto the beginning of a string
Prepend text
CopyRemove all occurrences of search from the current string.
remove: String search
Use the remove and remove_first filters to remove a string from another string
Remove text from the input string
CopyThe remove and remove_first filters are case-sensitive
Remove the first occurrence(s) of search from the current string.
remove_first: String searchInteger num_replacements
Use the remove and remove_first filters to remove a string from another string
Remove text from the input string
CopyThe remove and remove_first filters are case-sensitive
Replace all occurrences of search inside the current string with replacement
replace: String searchString replacement
Use the replace and replace_first filters to replace a string with another string inside the input
Replace text in the input string
CopyThe replace and replace_first filters are case-sensitive
Replace the first occurrence(s) of search inside the current string with replacement
replace_first: String searchString replacementInteger num_replacements
Use the replace and replace_first filters to replace a string with another string inside the input
Replace text in the input string
CopyThe replace and replace_first filters are case-sensitive
Replace all occurrences of pattern inside the current string with replacement using a regular expression - making it possible to search for more complicated expressions and replace using the resulting captured groups.
replace_regex: String patternString replacement
Use the replace_regex and replace_regex_first filters to use advanced matching logic to replace a string with another string inside the input
Replace text in the input string using a regex
CopyReplace the first occurrence(s) of pattern inside the current string with replacement using a regular expression - making it possible to search for more complicated expressions and replace using the resulting captured groups.
replace_regex_first: String patternString replacementInteger num_replacements
Use the replace_regex and replace_regex_first filters to use advanced matching logic to replace a string with another string inside the input
Replace text in the input string using a regex
CopyReverses the input string or list.
reverse
Use the reverse filter to reverse either a string or a list
Using the reverse filter
CopyWhen used on null input
When used on a string
When used on a list
Removes whitespace from the end of a string
rstrip
3 filters to remove whitespace from before and after strings
Various ways to strip whitespace from strings
CopyReturns the length of the input string or list.
size
Use the size filter to get the size of a string or a list
Using the size filter
CopyWhen used on null input
When used on a string
When used on a list
When used on anything else
Return a part of the current string or list.
slice: Integer startInteger length
Use the slice filter to get a portion of a string or list.
Using the slice filter
CopyWhen used on null input
When used on a string
When used on a list
With a negative start value
With a negative length
With a negative start and length
With length = 0
With a really large negative start
With start higher than the input length
With a calculated length less or equal to 0
Does not do anything if the object is not a string or a list
Split a string into a list of substrings separated by the given separator
split: String separator
Use the split filter to convert a string into a list of strings separated by the given separator
Using the split filter
CopySplit on multiple characters
Does not include empty strings in the result
Use an empty pattern to split the string into individual characters
Removes whitespace from the beginning and end of a string
strip
3 filters to remove whitespace from before and after strings
Various ways to strip whitespace from strings
CopyRemoves all HTML tags from a string
strip_html
Strip HTML from an input string
CopyThe quick brown fox jumps over the lazy dog.
' | strip_html}}The quick brown fox jumps over the lazy dog.
Could result in unexpected behavior with poorly formatted input
Could result in unexpected behavior with poorly formatted input
The following invalid markup contains an unescaped > character in an HTML attribute:
{%- endcapture -%} {{input | strip_html | strip}}Removes all newlines from a string
strip_newlines
Use the strip_newlines filter to remove all newlines from a string
Remove newlines from a string
CopyMultiply the input by the operand.
times: Number operand
Use the times filter to multiply a number by another number
You can currently use the times to multiply a string into a list of identical strings, although this behavior is deprecated. If you need this functionality you are advised to find a different way to accomplish it.
Using the times filter with a string
CopyCurrent functionality
Future functionality
Potential Replacement
Alternate Replacement
Truncates a string down to length characters. If the original string is longer than length characters, the result will end with truncate_string.
truncate: Integer lengthString truncate_string
Use the truncate, truncate_to_word, or truncate_words filter to shorten text to a specific number of characters or words.
Truncating text
Copytruncate
truncate_to_word
truncate_words
Truncates a string down to length characters. If the string would be broken in the middle of a word, ensures that the break happens either before or after the word. If the string is truncated it will end with truncate_string.
truncate_to_word: Integer lengthBoolean break_before_wordString truncate_string
Use the truncate, truncate_to_word, or truncate_words filter to shorten text to a specific number of characters or words.
Truncating text
Copytruncate
truncate_to_word
truncate_words
Truncates the input string down to length words. If the input is longer than length words, appends truncate_string to the end of the truncated string.
truncate_words: Integer lengthString truncate_string
Use the truncate, truncate_to_word, or truncate_words filter to shorten text to a specific number of characters or words.
Truncating text
Copytruncate
truncate_to_word
truncate_words
Convert a string to uppercase
upcase
Convert all characters in a string to uppercase.
Convert a string to uppercase
CopyDecode a url encoded string.
url_decode: Boolean formdata
Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.
Url Encoding and Decoding
Copyurl_encode
url_decode
Encode a string to be used in a URL.
url_encode: Boolean formdata
Use the url_encode and url_decode filters to encode strings for use in URLs, and to decode strings that have been url encoded.
Url Encoding and Decoding
Copyurl_encode
url_decode
Returns the 0-based index of the first occurrence of find in the current list or string, or -1 if it cannot be found. If start is greater than 0, the search will begin at the specified index.
index: object findInteger startBoolean ignorecase
Use the index and last_index filters to find a specific item in a list.
Find something in a list
Copyindex
last_index
Returns a string with each element from the input list joined together with the glue string between elements.
join
Use the join filter to join a list of strings together. Items in the list that are not already strings will be converted to a string before being joined together.
Join a list into a single string
CopyReturns the length of the input string or list.
size
Use the size filter to get the size of a string or a list
Using the size filter
CopyWhen used on null input
When used on a string
When used on a list
When used on anything else
Remove all duplicate objects in the input list. If property is specified, objects are considered duplicate if their property value is the same.
uniq: String propertyBoolean ignorecase
Use the uniq filter to remove duplicate items from a list.
Removing duplicates from a list
CopyUnique by property
Unique by property
Use the list methods and filters to create and manage lists of data in your templates
Getting and manipulating entity lists
CopyConcatenate and uniq the easy way
Concatenate manually
Unique manually
Get one random item from the list
Sort the full list randomly
Various ways to filter and slice
Advanced filter
Grouping
{{list.Key | default: "Unknown"}} Rooms ({{list.Value | size }} houses)
{% endfor %}Mapping and Compact
Returns the first item in the input list
first
Use the first and last filter to get a specific item in a list. In some cases, you can use square bracket notation to get an item at a specific index.
Getting a specific item from a list
Copyfirst
last
square bracket
Returns the last item in the input list
last
Use the first and last filter to get a specific item in a list. In some cases, you can use square bracket notation to get an item at a specific index.
Getting a specific item from a list
Copyfirst
last
square bracket
Reverses the input string or list.
reverse
Use the reverse filter to reverse either a string or a list
Using the reverse filter
CopyWhen used on null input
When used on a string
When used on a list
Sort objects in the input list. If the property is specified, use it to sort objects in the list. Use the special string value "random" to sort the list in a random order - which is functionally identicial to using the shuffle filter. The sort_natural filter ignores capitalization while the sort filter does not by default.
For readability and consistency, it is advised to use the sort filter with the ignorecase property set to true instead of the sort_natural filter.
sort_natural: String property
Use the sort, sort_natural, and shuffle filters to sort lists of objects. For consistency and readability, the sort filter should be preferred to the sort_natural filter.
Sorting lists
CopySort strings
Sort numbers
Sort objects
Sort randomly
Sort objects in the input list. If the property is specified, use it to sort objects in the list. Use the special string value "random" to sort the list in a random order - which is functionally identicial to using the shuffle filter.
sort: String propertyBoolean ignorecase
Use the sort, sort_natural, and shuffle filters to sort lists of objects. For consistency and readability, the sort filter should be preferred to the sort_natural filter.
Sorting lists
CopySort strings
Sort numbers
Sort objects
Sort randomly
Use the list methods and filters to create and manage lists of data in your templates
Getting and manipulating entity lists
CopyConcatenate and uniq the easy way
Concatenate manually
Unique manually
Get one random item from the list
Sort the full list randomly
Various ways to filter and slice
Advanced filter
Grouping
{{list.Key | default: "Unknown"}} Rooms ({{list.Value | size }} houses)
{% endfor %}Mapping and Compact
Split a string into a list of substrings separated by the given separator
split: String separator
Use the split filter to convert a string into a list of strings separated by the given separator
Using the split filter
CopySplit on multiple characters
Does not include empty strings in the result
Use an empty pattern to split the string into individual characters
Return a new list with the given property from every object in the input list.
map: String property
Use the map filter to map blog posts to their linked title. The map filter could just as easily be used for any other property as well.
Map a list of blog posts to their linked titles
CopyUse the list methods and filters to create and manage lists of data in your templates
Getting and manipulating entity lists
CopyConcatenate and uniq the easy way
Concatenate manually
Unique manually
Get one random item from the list
Sort the full list randomly
Various ways to filter and slice
Advanced filter
Grouping
{{list.Key | default: "Unknown"}} Rooms ({{list.Value | size }} houses)
{% endfor %}Mapping and Compact
Groups the list by the given property and returns the results as a list of objects. Each object in the result set has a Key property which is the value that they are grouped by and a Value property which is the list of objects that have the matching Key property. Any objects in the list that do not have the given property will be in a result with a null Key.
group_by: String property
Use the group_by filter to group objects by a specific property. For example, you can group a list of blog posts by blog.
Group blog posts by blog
Copy{{ group.Key.title }}: {{ group.Value | size }}
{% endfor %}Use the list methods and filters to create and manage lists of data in your templates
Getting and manipulating entity lists
CopyConcatenate and uniq the easy way
Concatenate manually
Unique manually
Get one random item from the list
Sort the full list randomly
Various ways to filter and slice
Advanced filter
Grouping
{{list.Key | default: "Unknown"}} Rooms ({{list.Value | size }} houses)
{% endfor %}Mapping and Compact
Returns the unencrypted value of the input string using a shared secret and optional salt. If no salt is provided, a default salt value is used.
decrypt_aes: String secretString salt
Use the encrypt_aes and decrypt_aes filters to encrypt and decrypt strings using the aes alrorithm.
Encrypt and decrypt strings with aes
Copyencrypt_aes
decrypt_aes
Returns the encrypted value of the input string using a shared secret and optional salt. If no salt is provided, a default salt value is used.
encrypt_aes: String secretString salt
Use the encrypt_aes and decrypt_aes filters to encrypt and decrypt strings using the aes alrorithm.
Encrypt and decrypt strings with aes
Copyencrypt_aes
decrypt_aes
Encodes a string to a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.
base64_url_safe_encode
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
Encoding and decoding from base64
Copybase64_encode
base64_decode
base64_url_safe_encode
base64_url_safe_decode
Decodes a string from a URL-safe base64 format. The difference between the base64 and URL-safe base64 formats is that the URL-safe format uses - and _ in place of + and /, which can cause problems when used in a URL.
base64_url_safe_decode
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
Encoding and decoding from base64
Copybase64_encode
base64_decode
base64_url_safe_encode
base64_url_safe_decode
Encodes a string to Base64 format
base64_encode
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
Encoding and decoding from base64
Copybase64_encode
base64_decode
base64_url_safe_encode
base64_url_safe_decode
Decodes a string from Base64 format
base64_decode
Use the base64_encode, base64_decode, base64_url_safe_encode, and base64_url_safe_decode filters to encode and decode strings to and from a base64 format.
Encoding and decoding from base64
Copybase64_encode
base64_decode
base64_url_safe_encode
base64_url_safe_decode
If the input is null, an empty string, or invalid (object.is_valid == false), return the default value. Otherwise returns the input. Note that if the input is the boolean value false, this will return false.
default: object default
Output a default value if the input string is empty
Default String
CopyProvide a default value for a numeric query parameter
Default Numeric Query Parameter
CopyReturns the input formatted as a string using the provided format string. There are three types of objects that can be formatted, and each type uses its own format strings.
Require a valid standard or custom .NET numeric format string. This is identical to using the format_number filter on a number.
If the input object is a string that can be converted to a date, it will be converted to a date before formatting. Otherwise if the input object is a string that can be converted to a number, it will be converted to a number before formatting.
format: String format
Format numbers using standard or custom .NET numeric format strings.
Format Numbers
CopyFormat dates using standard or custom .NET date formats.
Format Dates
CopyFormat time diffs using standard or custom.NET TimeSpan formats.
Format Time Diffs
CopyReturns a json-like representation of the current object up to depth layers deep (max 10). Will not load new information from the server unless forceLoad is set to true. Useful during template development and debugging, but do not rely on the result of the inspect tag for your live site.
inspect: Number depthBoolean force_load
Use the inspect filter to learn or troubleshoot the properties of an unknown field or object.
Inspect an uknown field
CopyReturns a string identifying the type of the input object. If generic_object_check is true, will return "object" for most objects. If generic_object_check is false or unspecified, will return the value of {{ object.object_type }} for objects with an object_type property.
object_type: Boolean generic_object_check
Use the object_type filter to get the type of an unknown property or variable.
Output the type of an unknown variable
CopyReturns a random value. Can behave differently depending on both the type of input and on the arguments supplied. Unless prevent_cache is false, the rand filter will prevent the page from being fast-cached. Note: the rand filter should NOT be considered cryptographically secure - do not use in places where cryptographic security is a requirement (ie: do not use to generate random passwords).
rand: Integer lengthBoolean allow_repeatsBoolean prevent_cache
Use the random filter to get a random number between 1 and 10. This will result in the page being unable to cached for faster future page loads.
Get a random number between 1 and 10
CopyUse the random filter to get a random number between 0 and 10, and allow the results to be cached for faster future page loads.
Get a random number between 0 and 10
CopyUse the random filter to get four random numbers between 1 and 10. The same number may be included multiple times in the resulting list. This will result in the page being unable to cached for faster future page loads.
Get 4 random numbers between 1 and 10
CopyUse the random filter to get four random numbers between 1 and 10, with no repeated numbers. This will result in the page being unable to cached for faster future page loads.
Get 4 unique random numbers between 1 and 10
CopyUse the rand filter to get a random character from a string
Get a random character from a string
CopyUse the rand filter to generate a random string 10 characters long, composed of letters and digits. The resulting string may include repeated characters.
Generate a random alphanumeric string 10 characters long
CopyUse the random filter to get a random blog post from a list of blog posts.
Get a random blog post from a list of blog posts
CopyUse the rand filter to get 3 random blog posts from a list of blog posts. Do not allow duplicates.
Get 3 random blog posts from a list of blog posts
CopyConverts the input to true or false if possible. If not returns null.
to_boolean
Convert a query parameter to a boolean value with a default value of true.
Convert to boolean
CopyConverts the input to a number.
to_number
Convert a query parameter to a number with a default value.
Convert to number
CopyConverts the input to an integer.
to_int
Convert a query parameter to an integer value with a default value.
Convert to integer
Copy