macro_rules! do_html {
($content:expr, $($key:ident = $val:expr),*) => { ... };
}Expand description
§do_html!($content, $key, and $val)
Macro Rules
The do_html macro takes HTML string content along with key-value pairs and replaces placeholders in the HTML (formatted as {{key}}) with the corresponding values.
It returns the processed HTML string with the substitutions applied.
§Parameters
$content: The HTML string content containing placeholders for substitution (e.g.,"<p>Hello, {{name}}!</p>").$key: The identifier for each placeholder in the HTML (e.g.,name).$val: The value that replaces the corresponding placeholder in the HTML (e.g.,"Alice").
§Examples
// use cans::content::do_html;
use cans::do_html;
let template = "<p>Hello, {{name}}! Welcome to {{place}}.</p>";
let result = do_html!(template, name = "Dear", place = "CANS Template");
assert_eq!(result, "<p>Hello, Dear! Welcome to CANS Template.</p>");End Doc