pub trait ClassPart {
// Required methods
fn write_to(&self, f: &mut Formatter<'_>) -> Result;
fn should_skip(&self) -> bool;
}Expand description
A trait for types that can be used as parts of a CSS class attribute.
This trait enables different types to participate in class merging via the classes! macro.
Implementations handle how each type writes its class value and whether it should be skipped.
§Provided Implementations
&str: Writes the string directly. Skipped if the string is empty.Option<&str>: Writes the inner string ifSome, skipped ifNoneor empty.
§Example
use plait::{html, classes, render};
let base = "btn";
let variant = Some("btn-primary");
let disabled: Option<&str> = None;
let html = render(html! {
button(class: classes!(base, variant, disabled)) { "Click" }
});
assert_eq!(html, "<button class=\"btn btn-primary\">Click</button>");Required Methods§
Sourcefn should_skip(&self) -> bool
fn should_skip(&self) -> bool
Returns true if this class part should be skipped when merging.