Skip to main content

ParserPlugin

Trait ParserPlugin 

Source
pub trait ParserPlugin {
    // Provided methods
    fn configure_parser(&mut self, _options: &ParserOptions) { ... }
    fn component_processing(&self) -> ComponentProcessing { ... }
    fn begin_fragment(&mut self, _context: FragmentContext<'_>) { ... }
    fn component_built(
        &mut self,
        _context: ComponentBuildContext<'_>,
    ) -> Result<()> { ... }
    fn process_attribute(
        &mut self,
        _context: AttributeContext<'_>,
    ) -> AttributeAction { ... }
    fn finish_opening_tag(
        &mut self,
        _context: ElementStartContext<'_>,
    ) -> Option<Vec<u8>> { ... }
    fn finish(self: Box<Self>) -> Result<ParserPluginArtifacts> { ... }
}
Expand description

A parser plugin that can customize template parsing behavior.

Plugins receive callbacks at explicit lifecycle points: parser setup, fragment start, component build, attribute processing, opening-tag completion, and build completion. Every callback has a no-op default.

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

Provided Methods§

Source

fn configure_parser(&mut self, _options: &ParserOptions)

Configure the plugin before parsing or component registration begins.

Source

fn component_processing(&self) -> ComponentProcessing

Return static component-processing behavior.

Source

fn begin_fragment(&mut self, _context: FragmentContext<'_>)

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 component_built(&mut self, _context: ComponentBuildContext<'_>) -> Result<()>

Called after a component template is fully built.

§Errors

Returns an error when the plugin cannot compile or retain the component.

Source

fn process_attribute( &mut self, _context: AttributeContext<'_>, ) -> AttributeAction

Process one authored attribute.

Source

fn finish_opening_tag( &mut self, _context: ElementStartContext<'_>, ) -> Option<Vec<u8>>

Called after all attributes on an opening tag have been processed. Returns optional opaque bytes to emit as a Plugin protocol fragment.

Source

fn finish(self: Box<Self>) -> Result<ParserPluginArtifacts>

Complete the build and return any captured artifacts.

§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".

Implementors§