Macro horrorshow::template [−][src]
macro_rules! template {
($name : ident($($field : ident : & $typ : ty), *) { $($tmpl : tt) * }
$($rest : tt) *) => { ... };
(pub $name : ident($($field : ident : & $typ : ty), *) { $($tmpl : tt) * }
$($rest : tt) *) => { ... };
() => { ... };
}
Expand description
Create a new template.
This allows you to declare a template as follows:
template! {
MyTemplate(name: &str, age: &u32) {
p {
: "Hello, my name is ";
: name;
: " and I am ";
: age;
: " years old.";
}
}
}
You can instantiate these templates by calling new
on them:
let age = 42;
let tmpl = MyTemplate::new("Not Me", &age);
These templates never own their content, they just borrow it. This is one of the reasons I call this feature “experimental”.