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
.
```cargo
[dependencies]
minijinja = { version = "2.6.0", features = ["loader"] }
```
use minijinja::{Environment, context};
fn main() {
let mut env = Environment::new();
env.add_template_owned(
"hello", "Hello, {{ name }}!".to_string()
).unwrap();
match env.get_template("hello") {
Ok(template) => {
match template.render(context!(name => "World")) {
Ok(output) => {
println!("{}", output);
}
Err(e) => { dbg!(e); ()}
}
}
Err(e) => { dbg!(e); ()}
}
}
Output:
Hello, World!
-- end of line --