Available on crate feature
typed
only.Expand description
Typed HTML nodes.
Examples
use html_node::typed::{self, elements::*};
// ^^^^^^^^^^^
// required to bring type definitions
// of all basic html elements into
// the current scope.
// (can also use `elements::div`, etc.)
// defines a custom element named `CustomElement`, with the specified attributes.
// underscores in attributes get converted to and from hyphens in the
// `typed::html!` macro and rendering to a string.
typed::element! {
CustomElement("custom-element") {
custom_attr,
}
}
// creates a normal `Node`, but checks types at compile-time!
let html = typed::html! {
<div id="container">
<CustomElement id="el" custom-attr="test" />
</div>
};
assert_eq!(
html.to_string(),
r#"<div id="container"><custom-element id="el" custom-attr="test"></custom-element></div>"#,
);
Modules
- Predefined HTML elements.
Macros
- Make a typed set of HTML attributes.
- Make a typed element.
- Make many typed elements.
- Make a typed HTML node.
Traits
- A typed set of HTML attributes.
- A typed HTML element.