TemplateProcessor

class TemplateProcessor(name: String, values: MutableMap<String, Any?> = mutableMapOf(), conditionals: MutableMap<String, Boolean> = mutableMapOf(), iterables: MutableMap<String, Iterable<Any>> = mutableMapOf())

A builder-like processor for a JTE (Java Template Engine) .jte template, identified by its precompiled template name (e.g. creator/main.qd.jte). Templates must be precompiled at build time via the JTE Gradle plugin and shipped on the runtime classpath; see the quarkdown-templates module for production templates.

Three main features:

  • Values: replace a placeholder in the template with a value. In JTE templates, values are referenced via ${NAME}.

  • Conditionals: show or hide fragments of the template code. In JTE templates, conditionals are expressed via @if(NAME)...@endif. An inverted (not) conditional is expressed via @if(!NAME)...@endif.

  • Iterables: repeat the content in their fragment as many times as the iterable's size, while replacing the placeholder with the current item during each iteration. In JTE templates, iterables are expressed via @for(item in NAME)${item}@endfor.

Parameters

name

template name as known by the precompiled JTE engine, relative to its source root

Constructors

Link copied to clipboard
constructor(name: String, values: MutableMap<String, Any?> = mutableMapOf(), conditionals: MutableMap<String, Boolean> = mutableMapOf(), iterables: MutableMap<String, Iterable<Any>> = mutableMapOf())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun conditional(conditional: String, value: Boolean): TemplateProcessor

Adds a conditional variable that shows or removes fragments of the template code.

Link copied to clipboard
fun copy(name: String = this.name): TemplateProcessor

Creates a copy of this template processor with the same injected properties.

Link copied to clipboard
fun iterable(placeholder: String, iterable: Iterable<Any>): TemplateProcessor

Adds an iterable to replace a placeholder in the template code.

Link copied to clipboard
fun optionalValue(placeholder: String, value: Any?): TemplateProcessor

Adds both a value to replace the placeholder (or null if absent), and registers it so that the template can check for null presence.

Link copied to clipboard
Link copied to clipboard
fun value(placeholder: String, value: Any?): TemplateProcessor

Adds a reference to a placeholder in the template code.