pub trait Component: Send + Sync {
// Required method
fn render(&self) -> Node;
// Provided methods
fn plain_text(&self) -> Option<String> { ... }
fn subject(&self) -> Option<&str> { ... }
}Expand description
The core trait for all Ferrum Email components.
Components are composable building blocks for email templates. Each component
defines how it renders to a Node tree, which the renderer then converts
to email-safe HTML.
§Examples
use ferrum_email_core::{Component, Node, node::Element, node::Tag};
struct HelloEmail {
name: String,
}
impl Component for HelloEmail {
fn render(&self) -> Node {
Node::text(format!("Hello, {}!", self.name))
}
fn subject(&self) -> Option<&str> {
Some("Hello!")
}
}Required Methods§
Provided Methods§
Sourcefn plain_text(&self) -> Option<String>
fn plain_text(&self) -> Option<String>
Optional: provide a custom plain text version.
If None, the renderer will auto-extract plain text from the node tree.