just_template_macros
Proc-macro crate for
just_template. Provides thetmpl!macro.
tmpl! macro
A unified macro for setting both simple parameters and implementation blocks
on a Template.
Simple parameters
use ;
let mut tmpl = from;
tmpl!;
// or, when the variable is named `tmpl`:
tmpl! ;
assert_eq!;
Implementation blocks with arms
use ;
let mut tmpl = from;
tmpl! ;
let out = tmpl.expand.unwrap;
// out contains:
// a => println!("a"),
// b => println!("b"),
Mixed with multi-param arms
use ;
let mut tmpl = from;
tmpl! ;
let out = tmpl.expand.unwrap;
// out contains:
// foo: 1
// bar: 2
// bar.extra()
Call forms
| Form | Example | Template variable |
|---|---|---|
| Explicit | tmpl!(tmpl, key = val) |
First argument |
| Implicit | tmpl! { key = val } |
Defaults to tmpl |
Both forms accept the same body syntax: simple params (key = val),
implementation blocks (name { arms }), or a mix of both.
For more details, see the just_template documentation.