A dynamic template engine that is fast, and makes zero allocations when rendering.
See the examples directory for examples!
{ for item in something.something.items } ... { end }
{ include template_name }
{ something.something.item }
To escape {
and }
, use {{
and }}
, respectively.
The macro is used so that you can pass your structs in as data to your templates.
rust
context! {
self: (TYPE PARAMETERS) TYPE {
key1 => self.value,
key2 => @iter self.iterable,
key3 => @raw self.html,
key4 => @{
key5 => self.another_value,
...
},
...
}
}
See the macros example if you're still not clear how this works. Also, note that all values must be contexts, too, and that at the bottom, strings, integers, etc. are the primitive contexts - it's contexts all the way down.
I couldn't find a template engine for Rust that: - was dynamic, allowing for changes to the templates without recompiling the entire program; and - allowed for structural sharing between the contexts of simultaneous renders.