2 Home
nillpoe edited this page 2026-09-29 08:18:48 +00:00

KMX

KMX is a template engine for Kotlin: XML markup with Kotlin expressions, like JSX. Each .kmx file compiles to Kotlin source, so kotlinc type-checks every expression, and rendering builds a tree that is always well-formed XML.

import com.example.Order

props: Order

<p>Order #{id}: {items.size} items</p>
OrderCard.render(order).toXml()   // <p>Order #1042: 2 items</p>

Pages

  • Expressions: where Kotlin can appear in a template, how its extent is found, which types each position accepts, name resolution, nullability, evaluation order, whitespace, escaping and error messages.
  • Generated Code: the Kotlin a template compiles to, statement by statement.
  • Editor Support: the IntelliJ IDEA plugin and the TextMate grammar, and how the plugin analyzes a template.

Setup, the module overview and a syntax tour are in the README.

Modules

Module Contents
kmx-runtime Node tree, XML writer, builder DSL, KmxTemplate, RenderScope
kmx-compiler Parser, code generator, kmxc command line
kmx-gradle-plugin xyz.nillpoe.kmx: compiles src/main/kmx into the main source set

KMX only renders templates. Quill builds mails on top of it.