macro_rules! insert_html {
({$contents:expr}, $($x:tt)*) => { ... };
}
Expand description
Takes a String and swaps the placeholder text {COMPONENT}
for the HTML String built using the provided syntax
First specify the String containing the placeholder text {COMPONENT}
. This string should be inserted in curly brackets {}
and have a comma inserted after the brackets.
Second specify the syntax describing the element to be inserted.
See documentation on html!
for more details on the syntax to use.
let test_contents = String::from("<div>{COMPONENT}</div>");
let result = insert_html!({test_contents}, span () "Hello World");
assert_eq!(result, "<div><span>Hello World</span></div>");