pub fn generate_compiled_template(tag_name: &str, html_content: &str) -> StringExpand description
Generate a compiled template as a raw JS IIFE string.
The output is a self-executing function that registers the component’s
metadata on window.__webui_templates[tagName]. During SSR, the
handler wraps one or more of these in a single <script> tag. During
SPA partial navigation, the router evaluates them directly.
§Flow
- Extract
@eventbindings from the<template>wrapper (→root_events). - Strip the
<template shadowrootmode="…">wrapper if present. - Compile the inner body via [
compile_to_metadata]. - Serialize into a self-executing IIFE that registers the metadata
on
window.__webui_templates[tagName].
§Compilation rules
| Source syntax | Metadata field(s) | Client h result |
|---|---|---|
{{expr}}, {{{expr}}}, mixed text | tx[] | dynamic text run removed |
href="{{url}}", class="x {{y}}" | a[] + ag[] | element kept marker-free |
?disabled="{{expr}}" | a[] + ag[] | element kept marker-free |
:config="{{settings}}" | a[] + ag[] | element kept marker-free |
<if condition="…">body</if> | c[] + cl[] + b[] | block removed; anchor slot stored |
<for each="v in coll">body</for> | r[] + rl[] + b[] | block removed; anchor slot stored |
<link> / <style> child nodes | h | preserved in static HTML |
| module adopted stylesheet specifier | sa | stored from <template> wrapper |
@event="{handler(e)}" | e[] + el[] | element kept marker-free |
w-ref="name" / w-ref={name} | (stays in HTML) | (unchanged) |
<outlet /> / <outlet> | (stays in HTML) | <outlet></outlet> |