Basic Structure For Minijinja With Multiple Templates Using A Struct In Rust

This works for specific, individual templates. I generally load an entire directory so I use >this instead>2ofddkppv9ik> as my goto

use minijinja::context;
use minijinja::Environment;
use minijinja::Source;
use serde::Serialize;
use std::fs;

#[derive(Debug, Serialize)]
struct Payload {
    data: Option<String>,

fn make_env<'a>(templates: Vec<(&'a str, &'a str)>) -> Environment<'a> {
    let mut env = Environment::new();
    let mut source = Source::new();
    for i in templates {
        let file_string = fs::read_to_string(i.1).unwrap();
        source.add_template(i.0, file_string).unwrap();

fn main() {
    let templates: Vec<(&str, &str)> =
        vec![("example", "src/bin/minijinja_structure_template.html")];
    let payload = Payload {
        data: Some("Minijinja".to_string()),
    let env = make_env(templates);
    let output = render_template(payload, env);

fn render_template(payload: Payload, env: Environment) -> String {
    let tmpl = env.get_template("example").unwrap();
    tmpl.render(context!(payload => &payload))

This uses `Source::new()`rust` to get the
templates instead of `.add_template()`rust
on an `Environment::new()`rust becuase that
doesn't work if you try to use it in a different