Skip to main content Skip to docs navigation

Template Functions

KorTE include some basic functions by default.

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

CYCLE

This functions allows to pick a value in a list in a cyclic way:

assertEquals("a", Template("{{ cycle(['a', 'b'], 2) }}")())
assertEquals("b", Template("{{ cycle(['a', 'b'], -1) }}")())

RANGE

Along the .. operator, allows you to create a range and to specify a custom step instead of the default 1.

assertEquals("[0, 1, 2, 3]", Template("{{ 0..3 }}")())
assertEquals("[0, 1, 2, 3]", Template("{{ range(0,3) }}")())
assertEquals("[0, 2]", Template("{{ range(0,3,2) }}")())

PARENT

This function is used inside a {% block %} block when used in inheritance to place the content of the block defined in ancestors. Acts like a super.myblock() in kotlin.

{% block myblock %}
    Before the default content
    {{ parent() }}
    After the default content
{% endblock %}
Was this article useful?