---
title: "Template"
sidebar_label: "Template"
description: "Kotlin binding reference: Template."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Template](index.md)

# Template

[common]\
class [Template](index.md)

A parsed, reusable text template (the engine the chat templates use): [parse](Companion/parse.md) once, [render](render.md) against a JSON object of variables as often as needed. Malformed syntax fails at [parse](Companion/parse.md); an undefined variable in a strict position or a type error fails at [render](render.md). `AutoCloseable`.

```kotlin
Template.parse("Hello {{ name }}!").use { greeting ->
    Json.newObject().set("name", "World").use { context -> greeting.render(context) }   // Hello World!
}
```

## Types

| Name | Summary |
|---|---|
| [Companion](Companion/index.md) | [common]<br>object [Companion](Companion/index.md) |

## Functions

| Name | Summary |
|---|---|
| [close](close.md) | [common]<br>open fun [close](close.md)() |
| [render](render.md) | [common]<br>fun [render](render.md)(context: [Json](../Json/index.md)): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>Render against [context](render.md), a JSON object whose members are the template's variables. |