wire.render
import wire.render
wiredoes not re-export this module, so it is reached only by importing it directly.
Walking a compiled template and writing the page out.
Nothing is parsed here and no markup is reassembled from text. The compiler already decided what every instruction is and what escaping every interpolation needs, so rendering is a walk that evaluates expressions and appends strings, and a value can never turn into structure on its way to the page.
The renderer is also the scope an expression is evaluated against: it is what answers what a name is bound to, what a filter does, and where to point when something goes wrong.
Classes
Frame
class wire.render.Frame
One level of variables, pointing at the level around it.
A loop pushes one of these rather than copying everything it can see, so iterating a long list costs one small dictionary per iteration instead of a copy of the whole page’s variables.
Fields
| Field | Type | Description |
|---|---|---|
variables | The variables bound at this level. | |
outer | The level around this one, or nil at the outermost. |
Constructor
wire.render.Frame(variables: dict, outer)
Parameters
variables(dict)outer(?Frame)
Frame.lookup()
wire.render.Frame.lookup(name: string) -> any
What name is bound to at this level or any level around it, or nil
when nothing binds it.
Parameters
name(string)
Returns any
Definition
class wire.render.Definition
One definition of a region, and what to render it against.
A region’s body does not always belong to the template placing it. An
extending template’s x-define is written against the same variables
the base is, so it renders in whatever scope is current. An include’s
children are written at the call site and have to render in the scope
they were written in, or <include path="card"><p>{{ orders|length }} </p></include>
would be asking the card about the caller’s orders and getting nothing.
Fields
| Field | Type | Description |
|---|---|---|
body | The instructions to render. | |
frame | The scope to render them in, or nil to use whatever is current. | |
path | The template the body was written in, for error messages. |
Constructor
wire.render.Definition(body: list, frame, path: string)
Parameters
body(list)frame(?Frame)path(string)
Renderer
class wire.render.Renderer
Renders compiled templates.
One of these is built per render and thrown away afterwards, so a compiled template can be rendered from several places at once without them treading on each other.
Fields
| Field | Type | Description |
|---|---|---|
environment | The Wire the render belongs to, which owns the filters, the registered elements, the loader and the compile… | |
path | The template currently being rendered, for error messages. | |
pieces | The pieces of the page so far, joined at the end. | |
frame | The variables in scope right now. | |
blocks | The regions an extending template supplied, keyed by name. | |
overridden | The definitions an x-super would reach, while a region is being rendered. | |
depth | How many includes and extends deep the render is. | |
line | The line of the instruction being rendered, for error messages. | |
column | The column of that instruction. |
Constructor
wire.render.Renderer(environment)
Parameters
environment(Wire)
Renderer.run()
wire.render.Renderer.run(template, variables: dict) -> string
Renders template with variables and returns the page.
Parameters
template(Template)variables(dict)
Returns string
Raises WireError
Renderer.template()
wire.render.Renderer.template(template, variables: dict, supplied: dict, depth: number)
Renders template, following whatever it extends and placing the regions it and its children define.
supplied holds regions coming from outside the inheritance chain, which is how an include hands its own children to the template it is including.
Parameters
template(Template)variables(dict)supplied(dict)depth(number)
Raises WireError
Renderer.nodes()
wire.render.Renderer.nodes(nodes: list)
Renders a list of instructions in order.
Parameters
nodes(list)
Renderer.node()
wire.render.Renderer.node(node)
Renders one instruction.
Parameters
node(Instruction)
Renderer.definition()
wire.render.Renderer.definition(definition)
Renders one definition of a region, in its own scope when it has one.
Parameters
definition(Definition)
Renderer.plain()
wire.render.Renderer.plain(segments: list) -> string
A run of segments joined with no escaping at all, for a template path.
Parameters
segments(list)
Returns string
Renderer.lookup()
wire.render.Renderer.lookup(name: string) -> any
What name is bound to, for an expression being evaluated.
Parameters
name(string)
Returns any
Renderer.apply_filter()
wire.render.Renderer.apply_filter(name: string, value, arguments: list) -> any
Runs the filter name over value, for an expression being evaluated.
Parameters
name(string)value(any)arguments(list)
Returns any
Raises RenderError when there is no such filter, or when the
filter rejects what it was given.
Renderer.fail()
wire.render.Renderer.fail(reason: string)
Stops the render, pointing at the instruction currently being rendered.
Parameters
reason(string)
Raises RenderError
2026, Richard Ore and The Zuri Contributors