Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

MiniJinja Basic Example

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!