render.rs
render.rs copied to clipboard
How to handle boolean attributes in HTML?
Certain HTML attributes, such as
We can have an enum type for HTML attributes (playground link), so:
enum HtmlAttribute {
StringValue(String, String),
BooleanValue(String, bool)
}
and use From<(String, String)> and From<(String, bool)> to generate HtmlAttribute — so the following syntax will be supported:
html! {
<button disabled={true} type="button" />
}
# will be almost like
::render::SimpleElement {
tag_name: "button",
attributes: [HtmlAttribute::from(("disabled", true), HtmlAttribute::from(("type", "button"))],
children: None
}
What do you think?
That seems reasonable