The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Load Multiple MiniJinja Templates From A Directory

TODO: Pull subtitle into page object
Code
//! ```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
Hello, Alan

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Load Multiple MiniJinja Templates From A Directory

-- code
-- 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/

Hello, Alan

-- /results

-- notes

- The path in the `template_dir`` variable has a file in 
it called `alfa.html`` 

- The content of `alfa.html`` is `Hello, {{ name }}``

- The `{{ name }}`` string gets replace with value
of `name`` from the `context!()``


-- categories
-- Rust 
-- MiniJinja

-- metadata
-- date: 2024-01-03 11:02:34
-- id: 2as2evj4
-- site: aws
-- type: post
-- status: published