korte

Template Engine for Multiplatform Kotlin

License

License

Categories

Categories

Data
GroupId

GroupId

com.soywiz.korlibs.korte
ArtifactId

ArtifactId

korte-metadata
Last Version

Last Version

2.0.8
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

korte
Template Engine for Multiplatform Kotlin
Project URL

Project URL

https://github.com/korlibs/korte
Source Code Management

Source Code Management

https://github.com/korlibs/korte

Download korte-metadata

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Korte

Korte

Template Engine for Multiplatform Kotlin

Build Status Maven Version Discord

Support korte

If you like korte, or want your company logo here, please consider becoming a sponsor ★,
in addition to ensure the continuity of the project, you will get exclusive content.

Info:

KorTE is an asynchronous templating engine for Multiplatform Kotlin 1.3+.

It is a non-strict super set of twig / django / atpl.js template engines and can support liquid templating engine as well with frontmatter.

It has out of the box support for ktor and vert.x.

It works on JVM and JS out of the box. And on Native with untyped model data or by making the models implement the DynamicType interface.

Because asynchrony is in its name and soul, it allows to call suspending methods from within your templates.

Documentation:

Live demo

Example

resources/views/_base.html

<html><head></head><body>
{% block content %}default content{% endblock %}
</body></html>

resources/views/_two_columns.html

{% extends "_base.html" %}
{% block content %}
    <div>{% block left %}default left column{% endblock %}</div>
    <div>{% block right %}default right column{% endblock %}</div>
{% endblock %}

resources/views/index.html

{% extends "_two_columns.html" %}
{% block left %}
    My left column. Hello {{ name|upper }}
{% endblock %}
{% block right %}
    My prefix {{ parent() }} with additional content
{% endblock %}

code.kt

val renderer = Templates(ResourceTemplateProvider("views"), cache = true)
val output = templates.render("index.html", mapOf("name" to "world"))
println(output)

class ResourceTemplateProvider(private val basePath: String) : TemplateProvider {
     override suspend fun get(template: String): String? {
         return this::class.java.classLoader.getResource(Paths.get(basePath, template).toString()).readText()
     }
 }
com.soywiz.korlibs.korte
Kotlin cORoutine Libraries for fullstack development - https://bintray.com/korlibs/korlibs - https://github.com/korlibs

Versions

Version
2.0.8
2.0.7