pub trait ParserPlugin: Any {
// Required methods
fn on_parse_component(
&mut self,
tag_name: &str,
component: &Component,
) -> Result<()>;
fn should_skip_attribute(&self, attr_name: &str) -> bool;
fn on_body_end(&mut self) -> Option<String>;
fn on_element_parsed(
&mut self,
binding_attribute_count: u32,
) -> Option<Vec<u8>>;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}Expand description
A parser plugin that can customize template parsing behavior.
Plugins receive callbacks at key points during HTML parsing:
- Component discovery:
on_parse_componentwhen a custom element is found - Attribute filtering:
should_skip_attributeto skip framework-specific attrs - Body end injection:
on_body_endto inject framework content before</body> - Element completion:
on_element_parsedafter attributes are processed
WebUI calls these hooks during parsing; plugins decide what (if anything) to do.
Required Methods§
Sourcefn on_parse_component(
&mut self,
tag_name: &str,
component: &Component,
) -> Result<()>
fn on_parse_component( &mut self, tag_name: &str, component: &Component, ) -> Result<()>
Called when a component element is encountered during parsing. Use to track components for later template generation.
Sourcefn should_skip_attribute(&self, attr_name: &str) -> bool
fn should_skip_attribute(&self, attr_name: &str) -> bool
Return true if this attribute should be skipped during parsing.
Framework-specific client-side bindings (e.g., @click, f-ref)
should be skipped since they are only meaningful at runtime.
Sourcefn on_body_end(&mut self) -> Option<String>
fn on_body_end(&mut self) -> Option<String>
Called when the </body> closing tag is encountered.
Returns optional raw HTML content to inject before </body>.
FAST uses this for <f-template> wrappers.
Sourcefn on_element_parsed(&mut self, binding_attribute_count: u32) -> Option<Vec<u8>>
fn on_element_parsed(&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.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Downcast to mutable Any for plugin-specific access.