Manuscript Documentation
v2026.12.0

@std/text/template.ms#

Import each required symbol with import Name from "@std/text/template.ms".

RenderOptions Type#

Settings for Template.render and Template.render_to.

Manuscript
type RenderOptions {
    partials Map[String, Template] = Map[String, Template]()
    strict Bool = true
    max_output Int? = null
    max_depth Int? = 64
}

RenderOptions.max_depth#

Optional maximum partial include depth; null imposes no limit.

Manuscript
max_depth Int? = 64

RenderOptions.max_output#

Optional maximum text length in bytes; null imposes no limit.

Manuscript
max_output Int? = null

RenderOptions.partials#

Templates that include can name.

Manuscript
partials Map[String, Template] = Map[String, Template]()

RenderOptions.strict#

When true, a missing printed path fails the render; when false, it prints as empty.

Manuscript
strict Bool = true

Template Type#

A compiled template; render it any number of times.

Manuscript
opaque type Template {
}

Template.render#

Renders the template with data and the settings in options. When data is an object, its members supply the root names.

Manuscript
fn render(data JsonValue, options RenderOptions = RenderOptions()) Result[String, Error]

Template.render_to#

Renders this template as render does and writes the text to output. The caller keeps output and closes it. A failed render writes nothing; a failed write returns the stream’s error.

Manuscript
fn render_to(data JsonValue, var output WriteStream[String], options RenderOptions = RenderOptions()) Result[Void, Error]

TemplateBranch Type#

One if or else if arm of a conditional node. Internal to the engine.

Manuscript
opaque type TemplateBranch {
}

TemplateExpr Enum#

A parsed template expression: a literal, a path, a filter call or an operator. Internal to the engine; hidden from callers.

Manuscript
opaque enum TemplateExpr {
}

TemplateNode Enum#

A parsed template node: text, a printed value, a conditional, a loop or an include. Internal to the engine.

Manuscript
opaque enum TemplateNode {
}

compile Function#

Compiles template source. With html: true, printed values are HTML-escaped unless the action ends in | raw.

Manuscript
fn compile(source String, html Bool = false) Result[Template, Error] { ... }

render Function#

Compiles and renders in one call, with default RenderOptions. Use compile when rendering more than once.

Manuscript
fn render(source String, data JsonValue, html Bool = false) Result[String, Error] { ... }

to_data Function#

Converts any Data value (records, lists, scalars) to the JsonValue that a template reads.

Manuscript
fn to_data[T Data](value T) Result[JsonValue, Error] { ... }