pub fn generate_compiled_template(
tag_name: &str,
html_content: &str,
) -> Result<String>Expand description
Generate a compiled template as JSON-safe metadata.
The returned string is the metadata data payload. Condition closures are
emitted separately by [generate_compiled_template_with_root_source].
§Flow
- Extract
@eventbindings from the<template>wrapper (→root_events). - Strip the open declarative Shadow DOM wrapper if present.
- Compile the inner body via [
compile_to_metadata]. - Serialize into JSON metadata and component-local condition closures.
§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 |
first concrete key="{{v.id}}" | optional fifth r[] field | relative repeat key path stored |
<link> / <style> child nodes | h | preserved in static HTML |
@event="{handler(e)}" | eg[] | element kept marker-free |
w-ref="name" / w-ref={name} | (stays in HTML) | (unchanged) |
<outlet /> / <outlet></outlet> | (stays in HTML) | <outlet></outlet> |
§Errors
Returns crate::ParserError::Template if the template contains an invalid
@event handler, non-braced w-ref, invalid concrete-child repeat key,
or an invalid, duplicate, unresolved, or item-incompatible named repeat.