Skip to main content

ClikaRT::tokenizer::Template

class

Header: ClikaRT/template/template.h

Text templating (Jinja2-compatible): parse a template once, render it many times against a json::Json context. Useful for prompt construction and any server-side text generation. For a model's chat template specifically, prefer Tokenizer::apply_chat_template (it applies the chat-format polyfills); Template is the general-purpose engine underneath.

A parsed, reusable template. Move-only.

Every fallible operation returns Result<T>; the library never throws. Turn a failure into an exception on your own side with .value_or_throw(), or inspect .ok() / .status() / .message().

Static member functions

parse()

static Template parse(std::string_view source)

Parse source. Malformed template syntax raises ClikaRT::Error. source is read during the call, not retained.

Declared in ClikaRT/template/template.h, line 34

Member functions

Template()

Template(Template&&) noexcept

Declared in ClikaRT/template/template.h, line 36

operator=()

Template& operator=(Template&&) noexcept

Move-assign: transfers the template.

Declared in ClikaRT/template/template.h, line 38

~Template()

~Template()

Releases the template.

Declared in ClikaRT/template/template.h, line 40

render()

std::string render(const json::Json& context) const

Render against context (the variables the template references). A render-time error (an undefined variable used in a strict position, a type error, a raised exception) raises ClikaRT::Error.

Declared in ClikaRT/template/template.h, line 46