Function | Description | Filter | Example |
string(value) | Converts an object to a string. | Supported | The result returned by {{ string(1.23) }} is 1.23. The value 1.23 is a string. |
capitalize(value) | Converts the first letter of a string to an uppercase letter and converts the other letters of the string to lowercase letters. | Supported | The result returned by {{ capitalize("heLLO World") }} is Hello world. |
lower(value) | Converts the uppercase letters in a string to lowercase letters. | Supported | The result returned by {{ lower("FOO") }} is foo. |
upper(value) | Converts the lowercase letters in a string to uppercase letters. | Supported | The result returned by {{ upper("foo") }} is FOO. |
title(value) | Converts a string to title case. In title case, the first letter of each word in a string is in uppercase, whereas the other letters of each word are in lowercase. | Supported | The result returned by {{ title("hello world") }} is Hello World. |
trim(value) | Deletes the empty characters at the beginning and end of a string. | Supported | The result returned by {{ trim(" foo\n") }} is foo. |
replace(value, old, new) | Replaces the specified characters of a string with new characters. | Not supported | The result returned by {{ replace("foo", "oo", "ly") }} is fly. |
wordcount(value) | Counts the number of words in a string. | Supported | The result returned by {{ wordcount("hello world") }} is 2. |
truncate(value, n, end='') | Truncates a string. - The n variable specifies the number of characters that you want to retain in the string.
- The end variable specifies the substring that you want to add to the string after the string is truncated.
| Not supported | - The result returned by
{{ truncate("foo bar", 5) }} is foo b. - The result returned by
{{ truncate("foo bar", 5, end="...") }} is foo b...
|
quote(value) | Encloses a string in a pair of double quotation marks (""). | Supported | - The result returned by
{{ quote(123) }} is "123". - The result returned by
{{ quote("foo") }} is "foo".
|
indent(value, n=4) | Indents each line of strings with a specified number of spaces. By default, each line of strings is indented with four spaces. You can use the n parameter to specify the number of spaces with which you want to indent each line of strings. | Supported | - For
{{ "foobar\n" }}{{ indent("foo\nbar") }} , the following result is returned:
- For
{{ "foobar\n" }}{{ indent("foo\nbar", 2) }} , the following result is returned:
|
startswith(value, prefix) | Checks whether a string starts with a specified substring. | Supported | The result returned by {{ startswith("football", "foo") }} is true. |
endswith(value, suffix) | Checks whether a string ends with a specified substring. | Supported | The result returned by {{ endswith("football", "all") }} is true. |
removeprefix(value, prefix) | Removes a specified substring from the start of a string. | Supported | The result returned by {{ removeprefix("football", "foot") }} is ball. |
removesuffix(value, suffix) | Removes a specified substring from the end of a string. | Supported | The result returned by {{ removesuffix("football", "ball") }} is foot. |
split(value, sep=None, maxsplit=-1) | Splits a string. | Supported | - The result returned by
{{ split('a b c ') }} is ['a', 'b', 'c']. - The result returned by
{{ split('a-b-c', sep='-') }} is ['a', 'b', 'c']. - The result returned by
{{ split('a-b-c', sep='-', maxsplit=1) }} is ['a', 'b-c']. - The result returned by
{{ split('a<>b<>c', sep='<>') }} is ['a', 'b', 'c'].
|