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 configure(&mut self, _options: &ParserOptions) { ... }
fn into_artifacts(self: Box<Self>) -> Result<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 plugin-facing 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 with the plugin-facing component template for the active CSS/DOM
strategies. Authored root <template> attributes are preserved here;
the SSR/internal parse view may strip runtime-only attributes.
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 configure(&mut self, _options: &ParserOptions)
fn configure(&mut self, _options: &ParserOptions)
Called when parser output options change.
Sourcefn into_artifacts(self: Box<Self>) -> Result<ParserPluginArtifacts>
fn into_artifacts(self: Box<Self>) -> Result<ParserPluginArtifacts>
Consume the plugin and return any build artifacts it captured.
§Errors
Returns an error if the plugin encountered an invalid template construct
while producing its artifacts (e.g. an invalid @event handler).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".