MiniJinja-Stack-Ref

Build Status License Crates.io rustc 1.61.0 Documentation

MiniJinja-Stack-Ref is a utility crate for MiniJinja that adds support for borrowing of dynamic values from the stack.

```rust use minijinja::{context, Environment}; use minijinjastackref::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.gettemplate("info").unwrap(); tmpl.render(context! { items => scope.seqobject_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