Skip to main content

ParserPlugin

Trait ParserPlugin 

Source
pub trait ParserPlugin {
    // Required methods
    fn register_component_template(
        &mut self,
        tag_name: &str,
        component: &Component,
        processed_template: &str,
    ) -> Result<()>;
    fn classify_attribute(&mut self, attr_name: &str) -> AttributeAction;
    fn finish_element(
        &mut self,
        binding_attribute_count: u32,
    ) -> Option<Vec<u8>>;

    // Provided methods
    fn start_fragment(&mut self, _fragment_id: &str) { ... }
    fn into_artifacts(self: Box<Self>) -> ParserPluginArtifacts { ... }
}
Expand description

A parser plugin that can customize template parsing behavior.

Plugins receive callbacks at key points during HTML parsing:

  • Fragment lifecycle: start_fragment before a fragment parse begins
  • Component registration: register_component_template when a component template is finalized
  • Attribute classification: classify_attribute for framework-specific attrs
  • Element completion: finish_element after attributes are processed

WebUI calls these hooks during parsing; plugins decide what (if anything) to do.

Required Methods§

Source

fn register_component_template( &mut self, tag_name: &str, component: &Component, processed_template: &str, ) -> Result<()>

Called when a component template has been fully processed for the active CSS strategy and wrapped for shadow DOM rendering.

Source

fn classify_attribute(&mut self, attr_name: &str) -> AttributeAction

Decide how a framework-owned attribute should be handled.

Source

fn finish_element(&mut self, binding_attribute_count: u32) -> Option<Vec<u8>>

Called after all attributes on an element have been processed. binding_attribute_count is the number of dynamic attribute bindings found. Returns optional opaque bytes to emit as a Plugin protocol fragment.

Provided Methods§

Source

fn start_fragment(&mut self, _fragment_id: &str)

Called before parsing begins for a fragment.

Plugins can use this to reset fragment-local counters while preserving global build-level state such as tracked component templates.

Source

fn into_artifacts(self: Box<Self>) -> ParserPluginArtifacts

Consume the plugin and return any build artifacts it captured.

Implementors§