Skip to main content

Module template

Module template 

Source
Expand description

Templates are compose documents with typed parameters, bound to data into plain specs.

A template is a compose document with a template header and params. Binding validates the data, then replaces {"$param": name} values, {{name}} in strings, and the $if, $switch and $each directives, and expands owner/name template nodes, leaving a spec with no $ left in it. Binding is logic-less and works on the JSON before it is parsed, so every compose field can be a parameter. One binding makes at most MAX_BOUND_VALUES values in template bodies.

Structs§

BindOptions
What binding takes besides the template and its data.
Issue
A problem lint finds.

Enums§

Severity
How serious an Issue is.

Constants§

MAX_BOUND_VALUES
Values one binding may make in template bodies, a string counting one per 64 bytes.

Functions§

bind
Binds document to data: a template’s parameters replaced and its template nodes expanded, giving a plain spec (or, for a node template, a plain node). A document without a header has only its template nodes expanded; directives and {{name}} exist only in template bodies. Without a header, template nodes or a theme, bind returns document unchanged.
data_schema
The JSON Schema (2020-12) of a template’s data, with each parameter’s title, description, default and checks a schema can say; file rules are in x-alpha2-media.
lint
Problems with a template, and with data for it when given: its header and parameters, the parameters its body names, literal content a template leaves to its data or theme, and whether it binds to a spec that parses. Without data it binds to sample data.