Filters

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 "objectName | filter_name:filterParams" (eg: {{ request.date | date: "MMM dd, YYYY" }}, 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 %}

General Filters

default String default_value
If the current variable is empty, return the default_value instead. Otherwise return the original value.
size
Return the size of the current list or string
slice: int start int len = 1
Return a part of the current string
downcase
Convert a string to lowercase
upcase
Convert a string to uppercase
url_encode
Encode a string to be used in a URL
url_decode
Decode a UrlEncoded string
capitalize
Capitalize words in a string
escape
Encode a string to be output as HTML. All special HTML characters will be converted to their equivalent HTML character entities (eg: < becomes &lt;)
h
Alias for Escape
truncate int length = 50 String truncate_string = "..."
Truncates a string down to length characters. If the original string is longer than length characters, appends truncate_string to the end of the truncated string.
truncate_words int length = 50 String truncate_string = "..."
Truncates a string down to length words. If the original string is longer than length words, appends truncate_string to the end of the truncated string.
split String pattern
Split a string into a list of substrings separated by the given pattern
strip_html
Removes all HTML tags from a string
strip_newlines
Removes all newlines from a string
join String glue = " "
Join the elements of a list into a single string with the glue string between each element.
sort String property (optional)
Sort objects in a list. If the property parameter is included, use it to sort objects in the list by.
map String property
Given a list of objects, return a new list with the given property from every object in the original list.
replace String search String replacement = ""
Replace all occurrences of search inside the current string with replacement.
replace_first String search String replacement = ""
Replace the first occurrence of search inside the current string with replacement.
remove String search
Remove all occurrences of search from the current string
remove_first String search
Remove the first occurrence of search from the current string
append String text
Add text to the end of the current string
prepend String text
Add text to the beginning of the current string
newline_to_br
Add "<br >" tags in front of all newlines in the current string
date String format (optional)
Converts the current value to a string using the given format, if specified. format must be a valid .NET date format.
first
Returns the first item in the current list.
last
Returns the last item in the current list
plus (string)object operand
Adds the operand to the current value. This filter behaves differently depending on the type of the current value and on the type of the operand (eg: {{4 | plus:2}} = 6, but {{'Some' | plus:'Thing'}} = 'SomeThing').

Date Filters

midnight
Return the DateTime representing midnight (UTC) for the current variable
add_minutes int operand
Return a DateTime object operand minutes in the future. If operand is negative, return a DateTime that many minutes in the past.
add_hours int operand
Return a DateTime object operand hours in the future. If operand is negative, return a DateTime that many hours in the past.
add_days int operand
Return a DateTime object operand days in the future. If operand is negative, return a DateTime that many days in the past.
add_months int operand
Return a DateTime object operand months in the future. If operand is negative, return a DateTime that many months in the past.
add_weeks int operand
Return a DateTime object operand weeks in the future. If operand is negative, return a DateTime that many weeks in the past.
add_years int operand
Return a DateTime object operand years in the future. If operand is negative, return a DateTime that many years in the past.

Math Filters

abs
Returns the absolute value of a number.
to_int
Converts a string into an integer. Useful when grabbing query parameters.
to_number
Converts a string into a number.
plus (number)object operand
Adds the operand to the current value. This filter behaves differently depending on the type of the current value and on the type of the operand (eg: {{4 | plus:2}} = 6, but {{'Some' | plus:'Thing'}} = 'SomeThing').
minus object operand
Subtracts the operand from the current value.
times object operand
This filter behaves differently depending on the type of the current value and on the type of the operand. If the current value is a string and the operand is an integer, repeats the current string operand times. Otherwise multiple the current input by the operand.
divide_by object operand
Divide the current value by operand.
modulo object operand
Return the remainder of the current value when divided by the operand.