pub trait HtmlAstNode {
// Required methods
fn node_tag_name() -> &'static str;
fn from_element(element: &Element) -> Self
where Self: Sized;
fn generate_tokens<FChildParser>(
&self,
context: &mut NodeContext<'_, FChildParser>,
ignore: &mut Vec<String>,
) -> TokenStream
where FChildParser: FnMut(&[Element], &mut TokenStream, &mut Vec<String>, &str) -> TokenStream;
}Expand description
Trait for all HTML abstract syntax tree (AST) nodes.
Defines how a node is created from an Element and how it generates Rust TokenStream.
Required Methods§
Sourcefn node_tag_name() -> &'static str
fn node_tag_name() -> &'static str
Returns the XML tag name for this node type (e.g., “if”, “select”).
Sourcefn from_element(element: &Element) -> Selfwhere
Self: Sized,
fn from_element(element: &Element) -> Selfwhere
Self: Sized,
Creates an instance of the node from a generic Element.
This method will extract necessary attributes and validate them.
Can panic if attributes are missing, similar to original code’s expect().
Sourcefn generate_tokens<FChildParser>(
&self,
context: &mut NodeContext<'_, FChildParser>,
ignore: &mut Vec<String>,
) -> TokenStream
fn generate_tokens<FChildParser>( &self, context: &mut NodeContext<'_, FChildParser>, ignore: &mut Vec<String>, ) -> TokenStream
Generates the Rust TokenStream for this specific AST node.
The ignore vector is passed directly to allow modification by calling nodes (e.g. for <foreach> scope).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".