11 unstable releases (3 breaking)
new 0.30.7 | Mar 17, 2023 |
---|---|
0.30.6 | Mar 8, 2023 |
0.30.4 | Feb 13, 2023 |
0.30.2 | Jan 28, 2023 |
0.27.0 | Dec 11, 2022 |
#242 in Template engine
564 downloads per month
Used in curlz
535KB
11K
SLoC
MiniJinja-Stack-Ref
MiniJinja-Stack-Ref is a utility crate for MiniJinja that adds support for borrowing of dynamic values from the stack.
use minijinja::{context, Environment};
use minijinja_stack_ref::scope;
let mut env = Environment::new();
env.add_template(
"info",
"app version: {{ state.version }}\nitems: {{ items }}"
)
.unwrap();
let items = [1u32, 2, 3, 4];
let rv = scope(|scope| {
let tmpl = env.get_template("info").unwrap();
tmpl.render(context! {
items => scope.seq_object_ref(&items[..]),
}).unwrap()
});
println!("{}", rv);
For an example have a look at the stack-ref example.
Sponsor
If you like the project and find it useful you can become a sponsor.
License and Links
- Documentation
- Issue Tracker
- License: Apache-2.0