Home

Load Multiple MiniJinja Templates From A Directory

rust
//! ```cargo
//! [dependencies]
//! minijinja = { version = "1.0.10", features = ['loader'] }
//! ```

use minijinja::{Environment, context, path_loader};

fn main() {
  let template_dir = "/Users/alan/workshop/_examples/minijinja-templates";
  let mut env = Environment::new();
  env.set_loader(path_loader(template_dir));
  let template = env.get_template("alfa.html").unwrap();
  let output = template.render(context!(name => "Alan")).unwrap();
  println!("{}", output);
}
results start

- The path in the [TODO: Code shorthand span ] variable has a file in it called [TODO: Code shorthand span ]

- The content of [TODO: Code shorthand span ] is [TODO: Code shorthand span ]

- The [TODO: Code shorthand span ] string gets replace with value of [TODO: Code shorthand span ] from the [TODO: Code shorthand span ]

~ fin ~