pub fn html(html_string: String) -> ElementExpand description
Create a Virtual Dom of rust_fel::Element from a string of HTML.
§Arguments
html_string- Must have a parent wrapping HTML Element. All text must have a wrapping HTML Element. Text and non text HTML Elements cannot be siblings.
§Examples
use rust_fel::html;
let html = html(
"<div |class=classname|><span |role=button|>Span Text</span><p>Paragraph Text</p></div>"
.to_owned(),
);
assert_eq!(html.html_type, "div".to_owned());
assert_eq!(html.props.class_name.unwrap(), "classname".to_owned());
let children = html.props.children.unwrap();
let first_child = children.iter().nth(0);
let second_child = children.iter().nth(1);
assert_eq!(first_child.unwrap().html_type, "span");
assert_eq!(first_child.unwrap().props.role.as_ref().unwrap(), "button");
assert_eq!(second_child.unwrap().html_type, "p");
let second_childs_child = &second_child
.unwrap()
.props
.children
.iter()
.nth(0)
.unwrap()
.iter()
.nth(0)
.unwrap();
assert_eq!(second_childs_child.html_type, "TEXT_ELEMENT");