Skip to main content

generate_compiled_template

Function generate_compiled_template 

Source
pub fn generate_compiled_template(tag_name: &str, html_content: &str) -> String
Expand description

Generate a compiled template <script> block with a metadata object.

§Flow

  1. Extract @event bindings from the <template> wrapper (→ root_events).
  2. Strip the <template shadowrootmode="…"> wrapper if present.
  3. Compile the inner body via [compile_to_metadata].
  4. Serialize into a self-executing <script> IIFE that registers the metadata on window.__webui_templates[tagName].

§Compilation rules

Source syntaxMetadata field(s)Client h result
{{expr}}, {{{expr}}}, mixed texttx[]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 nodeshpreserved in static HTML
module adopted stylesheet specifiersastored 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>