pub trait Htmlifiable {
// Required method
fn html(&self) -> String;
}Expand description
Used to be converted to html string
Required Methods§
Sourcefn html(&self) -> String
fn html(&self) -> String
Convert the object to html string.
use html_query_parser::{Node, Element, Htmlifiable};
let node: Node = Node::new_element(
"span",
vec![("class", "info")],
vec![
Node::Text("Hello World!".to_string())
]
);
assert_eq!(node.html(), r#"<span class="info">Hello World!</span>"#);
let nodes: Vec<Node> = vec![node.clone()];
assert_eq!(nodes.html(), r#"<span class="info">Hello World!</span>"#);
let element: Element = node.try_into_element().unwrap();
assert_eq!(element.html(), r#"<span class="info">Hello World!</span>"#);