wire.constants
import wire
wireexposes this aswire.constants, soimport wireis enough and the names are called aswire.constants.*.import wire.constantsreaches the same definitions directly.
The names Wire reserves: its directive attributes, the pseudo elements
that are sugar for them, and the handful of defaults the Wire class
starts out with.
Everything a template author can type that Wire treats specially is named here rather than spelled inline, so the answer to “is this attribute mine?” only ever has one place to live.
Constants
DIRECTIVE_PREFIX
wire.constants.DIRECTIVE_PREFIX = 'x-'
The prefix every Wire directive attribute carries.
Wire owns this prefix outright: an attribute starting with x- that
Wire does not recognize is a compile error rather than a passthrough,
which is what turns a typo like x-fi into a message instead of a
silently missing section. Markup that genuinely needs an x- prefixed
attribute in the output can emit one through x-attr.
CARRIER_TAG
wire.constants.CARRIER_TAG = 'template'
The element Wire uses to carry a directive without emitting anything of its own.
<template> is the only HTML element the tree construction algorithm
lets through untouched everywhere: inside <head>, inside a table,
inside a <select>. Every other name would be relocated or dropped by
the parser before Wire ever saw it, which is why Wire’s own pseudo
elements are rewritten into this one while the source is being
tokenized.
IF_ATTR
wire.constants.IF_ATTR = 'x-if'
Renders the element only when the expression is truthy.
ELIF_ATTR
wire.constants.ELIF_ATTR = 'x-elif'
Continues an x-if chain on the next element sibling.
ELSE_ATTR
wire.constants.ELSE_ATTR = 'x-else'
Closes an x-if chain on the next element sibling. Valueless.
NOT_ATTR
wire.constants.NOT_ATTR = 'x-not'
Renders the element only when the expression is falsy, the inverse of
x-if.
FOR_ATTR
wire.constants.FOR_ATTR = 'x-for'
Repeats the element once per entry of the expression’s value.
VALUE_ATTR
wire.constants.VALUE_ATTR = 'x-value'
Names the variable each x-for iteration binds its value to.
KEY_ATTR
wire.constants.KEY_ATTR = 'x-key'
Names the variable each x-for iteration binds its key or index to.
LOOP_ATTR
wire.constants.LOOP_ATTR = 'x-loop'
Renames the loop metadata variable an x-for publishes, which is called
loop unless this says otherwise.
TEXT_ATTR
wire.constants.TEXT_ATTR = 'x-text'
Replaces the element’s children with the expression’s value as text.
HTML_ATTR
wire.constants.HTML_ATTR = 'x-html'
Replaces the element’s children with the expression’s value as markup, without escaping it.
ATTR_ATTR
wire.constants.ATTR_ATTR = 'x-attr'
Spreads a dictionary of name/value pairs onto the element as attributes.
INCLUDE_ATTR
wire.constants.INCLUDE_ATTR = 'x-include'
Renders another template in this element’s place.
WITH_ATTR
wire.constants.WITH_ATTR = 'x-with'
Supplies the variables an x-include or a component is rendered with.
ONLY_ATTR
wire.constants.ONLY_ATTR = 'x-only'
Withholds the surrounding scope from an x-include or a component,
leaving it only what x-with passes. Valueless.
EXTEND_ATTR
wire.constants.EXTEND_ATTR = 'x-extend'
Marks this template as extending the base template named by the value.
SLOT_ATTR
wire.constants.SLOT_ATTR = 'x-slot'
Declares a region an extending template may replace.
DEFINE_ATTR
wire.constants.DEFINE_ATTR = 'x-define'
Replaces the base template’s region of the same name.
OVERRIDE_ATTR
wire.constants.OVERRIDE_ATTR = 'x-override'
Permits an x-define to replace a definition of the same name made
earlier in the same template. Valueless.
SUPER_ATTR
wire.constants.SUPER_ATTR = 'x-super'
Renders the definition this one replaces. Valueless.
DIRECTIVES
wire.constants.DIRECTIVES = [...]
Every directive attribute Wire understands.
A template carrying an x- prefixed attribute outside this list is
rejected at compile time.
EXPRESSION_DIRECTIVES
wire.constants.EXPRESSION_DIRECTIVES = [...]
The directives whose value is a Wire expression.
NAME_DIRECTIVES
wire.constants.NAME_DIRECTIVES = [...]
The directives whose value names a variable or a region, and is read as a bare identifier rather than evaluated.
PATH_DIRECTIVES
wire.constants.PATH_DIRECTIVES = [...]
The directives whose value is a template path, read as literal text with
{{ }} interpolation allowed inside it.
FLAG_DIRECTIVES
wire.constants.FLAG_DIRECTIVES = [...]
The directives that take no value at all.
PSEUDO_ELEMENTS
wire.constants.PSEUDO_ELEMENTS = {...}
The pseudo elements Wire accepts as sugar, each mapped to the directive it becomes and the attribute that carries the directive’s value.
These are rewritten into <template> while the source is being
tokenized, so by the time a tree exists there is only one form left to
compile. attribute is nil for a pseudo element that takes no value
of its own.
PSEUDO_FLAGS
wire.constants.PSEUDO_FLAGS = {...}
Attributes a pseudo element may carry that become valueless directives rather than the directive its name maps to.
Only <define name="x" override> uses this today, which is why the
mapping is a single entry rather than a per-element table.
VAR_OPEN
wire.constants.VAR_OPEN = '{{'
Opens an interpolation.
VAR_CLOSE
wire.constants.VAR_CLOSE = '}}'
Closes an interpolation.
CALL_OPEN
wire.constants.CALL_OPEN = '{!'
Opens a template function call.
CALL_CLOSE
wire.constants.CALL_CLOSE = '!}'
Closes a template function call.
ESCAPE_CHAR
wire.constants.ESCAPE_CHAR = '%'
The character that escapes an interpolation, making Wire emit the braces literally instead of reading what is between them.
DEFAULT_EXTENSION
wire.constants.DEFAULT_EXTENSION = '.html'
The extension render() appends when the path it was given does not
name an existing file and carries no extension of its own.
DEFAULT_ROOT
wire.constants.DEFAULT_ROOT = 'templates'
The directory render() resolves template paths against until
set_root() says otherwise, which is a templates directory beside the
current working directory.
DEFAULT_LOOP_NAME
wire.constants.DEFAULT_LOOP_NAME = 'loop'
The variable an x-for publishes its loop metadata under.
MAX_DEPTH
wire.constants.MAX_DEPTH = 64
How deep x-include and x-extend may nest before Wire calls it a
cycle.
A template that includes itself would otherwise recurse until the process died, and the depth a legitimate layout hierarchy reaches is nowhere near this.
2026, Richard Ore and The Zuri Contributors