| Crates.io | minijinja-stack-ref |
| lib.rs | minijinja-stack-ref |
| version | 1.0.22 |
| created_at | 2022-12-11 13:49:20.800038+00 |
| updated_at | 2025-05-06 10:13:42.555355+00 |
| description | dynamic stack references for MiniJinja |
| homepage | https://github.com/mitsuhiko/minijinja |
| repository | https://github.com/mitsuhiko/minijinja |
| max_upload_size | |
| id | 734351 |
| size | 33,305 |
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.
If you like the project and find it useful you can become a sponsor.