render.rs icon indicating copy to clipboard operation
render.rs copied to clipboard

How to handle boolean attributes in HTML?

Open vpzomtrrfrt opened this issue 5 years ago • 2 comments

Certain HTML attributes, such as

vpzomtrrfrt avatar Jul 08 '20 04:07 vpzomtrrfrt

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?

Schniz avatar Jul 08 '20 06:07 Schniz

That seems reasonable

vpzomtrrfrt avatar Jul 08 '20 14:07 vpzomtrrfrt