pub trait Value: Sealed { }Expand description
Types that can be used as attribute values in the html! macro.
where T: Render
§Examples
Passing a bool conditionally renders a boolean attribute.
let checked = true;
let markup = html! {
input r#type: "checkbox" checked: (checked);
};
assert_eq!(markup.render().0, r#"<input type="checkbox" checked>"#);To conditionally include an attribute with a value, pass an Option<T>.
The attribute is only rendered when the value is Some.
let cooldown = Some("200ms");
let markup = html! {
button data_cooldown: (cooldown) {
"click me"
}
};
assert_eq!(markup.render().0, r#"<button data-cooldown="200ms">click me</button>"#);