Skip to main content

attr

Macro attr 

Source
macro_rules! attr {
    ($name:literal) => { ... };
}
Expand description

Builds an Attr for a name with no constant in html::attr.

Such a name is a data-* attribute, such as data-lat, or an attribute of a custom element. The name is checked at compile time against the rules of Attr, so a name that could run a script stops the build:

use hypersig::html::div;

let map = div::<()>().attr(hypersig::attr!("data-zoom"), "12");
assert!(map.render().contains(r#"data-zoom="12""#));
ⓘ
let _ = hypersig::html::img::<()>().attr(hypersig::attr!("onerror"), "alert(1)");