Add 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
CopyEncode 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
CopyUse 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
CopyReturns 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
Null values output the string "null". Dates are output using the ISO 8601 standard. Booleans are output as "true" or "false". Numbers are output as numbers. Strings are output as json encoded strings with quote marks properly escaped.
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
The plus filter may behave differently when used with string input. When used with a string input it may append text to the current value, although that behavior is deprecated and should be replaced by the append filter for optimal forward-compatibility.
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
When used with a string as input, the result is a string. Otherwise the result is a list.
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
If the input is not a string or list returns 0.
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
If the input is a string this will return a string. If it is a list it will return a list. Otherwise it will not do anything and will return the unaltered input.
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
This filter uses simple pattern matching to remove HTML tags. If the input is poorly formatted or contains unusual character sequences - particularly involving the '<' and '>' characters - this could result in unexpected behavior.
Strip HTML from an input string
CopyCould result in unexpected behavior with poorly formatted input
Could result in unexpected behavior with poorly formatted input
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
This filter currently behaves differently if the input is a string and the operand is an integer. In that case the result is a list of strings with input repeated operand times.
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
The truncate_to_word uses a naive algorithm for word counting that considers words as one or more letters, digits, underscores, or apostrophes. All other characters are considered non-word characters in between words. This means that a string could still be truncated in the middle of a hypenated word or a word with other non-word characters such as "awe-inspiring", "r&r", "1.25", "3/4", etc.... This filter also does not strip or consolidate whitespace, or handle HTML markup any different than normal text.
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
The truncate_words uses a naive algorithm for word counting that considers words as one or more letters, digits, underscores, or apostrophes. All other characters are considered non-word characters in between words. This means that hyphenated words such as "awe-inspiring" are counted as two words, as are "words" with other characters between letters, such as "r&r", "1.25", "3/4", etc.... This filter also does not strip or consolidate whitespace, or handle HTML markup any different than normal text.
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