Expand description
WebUI Framework parser plugin.
§Overview
Compiles HTML templates into structured metadata objects stored as JSON
data plus component-local condition closure arrays in the protocol.
During SSR the handler emits metadata in an application/json data block
and only emits the closures as JavaScript. During SPA navigation the
router registers the JSON data directly and evaluates only the closures.
Each metadata object contains
marker-free static HTML plus locator arrays for client-created DOM
(tx, ag, c/r slots) and semantic arrays (a, c, r, eg,
re, b). The client runtime resolves those locators once and then
patches direct node references — no template string parsing, no regex,
no DOM scanning on the client-created path.
§Metadata object format
{
"h": "<button class=\"item\"><span></span></button>",
"tx": [[[[0, 0], 0], [["title"]]]],
"a": [["title", 0, "title"]],
"ag": [[[0], 0, 1]],
"c": [[[0, ["state"]], 0, [[0], 1]]],
"eg": [["click", [["onClick", [], [0]]]]],
"b": [{ "h": "<span class=\"check\">✓</span>" }],
"sa": "my-component",
"re": [["submit", "onSubmit", [["e"]]]]
}§Plugin data protocol
Each element with attribute bindings or events produces a 12-byte
Plugin fragment via finish_element:
| Bytes | Field | Description |
|---|---|---|
| 0–3 | binding_count | Number of dynamic attribute bindings |
| 4–7 | event_start_idx | Starting index in the global event list |
| 8–11 | event_count | Number of @event attrs on this element |
The handler plugin decodes this to emit data-w-* binding markers
and single data-ev="COUNT" event markers on SSR HTML only. Compiled templates
keep the same binding/event indices but encode client targets via locator
arrays instead of embedding client-only marker attrs/comments in h.
§Lifecycle
classify_attribute— intercepts@eventattributes, counts them per-element, and keeps them out of the parsed protocol.finish_element— encodes the accumulated event count plus attribute binding count into 12 bytes.register_component_template— caches the component’s plugin-facing template HTML for later compilation (deduplicates by tag name).take_component_templates— called after parsing is complete; compiles each tracked component into JSON metadata plus condition closures.
Structs§
- WebUI
Parser Plugin - WebUI Framework parser plugin.
Functions§
- generate_
compiled_ template - Generate a compiled template as JSON-safe metadata.