home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

MiniJinja Basic Example

January 2024

This is a basic MiniJinja example. It's pulled directly from the docs with one change. It uses `.add_template_owned() instead of `.add_template() so that strings (i.e. `String) can be used instead of `&str.

Code
```cargo
[dependencies]
minijinja = { version = "1.0", features = ["loader"] }
```

use minijinja::{Environment, context};

fn main() {
    let mut env = Environment::new();
    env.add_template_owned(
        "hello", "Hello {{ name }}!".to_string()
    ).unwrap();
    let skeleton = env.get_template("hello").unwrap();
    let output = skeleton.render(context!(name => "World")).unwrap();
    println!("{}", output);
}
Results
Hello World!
═══ § ═══