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_fragmentbefore a fragment parse begins - Component registration:
register_component_templatewhen a component template is finalized - Attribute classification:
classify_attributefor framework-specific attrs - Element completion:
finish_elementafter attributes are processed
WebUI calls these hooks during parsing; plugins decide what (if anything) to do.
Required Methods§
Sourcefn register_component_template(
&mut self,
tag_name: &str,
component: &Component,
processed_template: &str,
) -> Result<()>
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.
Sourcefn classify_attribute(&mut self, attr_name: &str) -> AttributeAction
fn classify_attribute(&mut self, attr_name: &str) -> AttributeAction
Decide how a framework-owned attribute should be handled.
Provided Methods§
Sourcefn start_fragment(&mut self, _fragment_id: &str)
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.
Sourcefn into_artifacts(self: Box<Self>) -> ParserPluginArtifacts
fn into_artifacts(self: Box<Self>) -> ParserPluginArtifacts
Consume the plugin and return any build artifacts it captured.