Skip to main content Skip to docs navigation

Template Filters

KorTE include some basic filters by default.

Document not reviewed yet, might be outdated. Please, let us know if you find something invalid here.
On this page

CAPITALIZE

Changes the first letter of the string to be uppercased.

{{ "hellO"|capitalize }}

HellO

LOWER

Changes all the letter characters of the string to lower case.

{{ "HELLo"|lower }}

hello

UPPER

Changes all the letter characters of the string to upper case.

{{ "hellO"|upper }}

HELLO

JOIN

Joins elements in an array as a string, with a separator

{{ [1,2,3,4]|join(":") }}

1:2:3:4

LENGTH

Gets the number of elements in an array, or the number of characters in a string

{{ ['a', 'b', 'c']|length }}, {{ "hi"|length }}

3, 2

QUOTE

Adds c-type quotes to a string

{{ "I'm a test"|quote }}

"I\'m a test"

REVERSE

Reverses the characters in a string, or the elements in an array or list.

{{ "hello"|reverse }}, {{ [1,2,3]|reverse }}

olleh, [3,2,1]

RAW

Taints the string to not be auto escaped.

{{ "<test>" }}, {{ "<test>"|raw }}

&lt;test&gt;, <test>

SORT

Sorts all the elements in the provided array.

{{ [10, 4, 7, 1]|sort }}

[1,4,7,10]

TRIM

Remove spaces, tabs and line breaks from the beginning and the end of the string.

{{ "   hello   "|trim }}

hello

MERGE

Combines two lists together.

{{ [1, 2, 3]|merge([4, 5, 6]) }}

[1,2,3,4,5,6]

JSON_ENCODE

Converts an arbitrary object into a JSON string.

{{ ["a", "b"]|json_encode }}

["a", "b"]

FORMAT

C-type formatting.

{{ "hello %03d"|format(7) }}

hello 007

CHUNKED

Split a list into several lists of a specific size.

{{ [1,2,3,4,5]|chunked(2) }}

[[1,2],[3,4],[5]]

Was this article useful?