Today I have just released the first version of Korte.
KorTE is a Template Engine for Multiplatform Kotlin 1.3.
It is mostly compatible with twig
, django
, atpl.js
and liquid
. Can be used from any Kotlin target including JS, JVM and Kotlin/Native. And includes a couple of artifacts to use it easily from Ktor
and Vert.x
.
It supports template inheritance, blocks, tags, functions, advanced expressions, filters and calling suspend methods and accessing properties out of the box.
<html><head></head><body>
{ % block content % }default content{ % endblock % }
</body></html>
{ % extends "_base.html" % }
{ % block content % }
<div>{ % block left % }default left column{ % endblock % }</div>
<div>{ % block right % }default right column{ % endblock % }</div>
{ % endblock % }
{ % extends "_two_columns.html" % }
{ % block left % }
My left column
{ % endblock % }
{ % block right % }
My prefix { { parent() } } with additional content
{ % endblock % }
It is fully documented here: https://korlibs.soywiz.com/korte/
And the source code lives here: https://github.com/korlibs/korte
And there is an online demo running it in javascript: https://korlibs.github.io/korte-samples/korte-sample-browser/web/