HTML authoring in Slim
Write regular HTML, add Xuda directives, and let Slim turn it into a program tree.
HTML authoring is the most direct way to learn Slim. Instead of a compiler, you write ordinary HTML and add Xuda directives that bind fields, compute output, toggle visibility, run actions, or iterate over data.
Mental model
- normal HTML for structure
- datasource fields for state
@field_nameexpressions for reads- Xuda directives for wiring behavior
A full page
How <template> becomes a program
When the page contains <template> tags, Slim reads every one of them, uses the template's id
attribute as the program id (or template_<index> when there is no id), parses the markup into
progUi, and stores the result under _session.project_data.programs. With no prog_id supplied,
the first template on the page becomes the startup program.
Templates are optional. If you already pass project_data, templates extend that data rather than
replacing it.
Common HTML directives
The full directive reference, including expressions and events, is on Runtime directives.
Attribute value parsing
Template attributes that look like JSON, an array ([...]), an object ({...}) or a quoted JSON
string, are parsed with JSON.parse. A valid one becomes a real object or array in progUi; an
invalid one stays a plain string. xu-store is the exception: its handler parses with JSON5, so
JSON5-style syntax (unquoted keys, single quotes) still works there.
When HTML authoring is the better fit
Use it for docs pages, microsites, product landing pages, embedded widgets and hand-authored
prototypes. Move to the CLI once the app grows into
multiple routed features, persistence logic needs a clearer home, or several unit types such as
get_data, set_data and batch should live outside the page.