Skip to main content

ParserPlugin

Trait ParserPlugin 

Source
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_component when a custom element is found
  • Attribute filtering: should_skip_attribute to skip framework-specific attrs
  • Body end injection: on_body_end to inject framework content before </body>
  • Element completion: on_element_parsed after attributes are processed

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

Required Methods§

Source

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.

Source

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.

Source

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.

Source

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.

Source

fn as_any(&self) -> &dyn Any

Downcast to Any for plugin-specific access.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast to mutable Any for plugin-specific access.

Implementors§