rocket_dyn_templates::minijinja

Function path_loader

Source
pub fn path_loader<'x, P>(
    dir: P,
) -> impl for<'a> Fn(&'a str) + Send + Sync + 'static
where P: AsRef<Path> + 'x,
Expand description

Helper to load templates from a given directory.

This creates a dynamic loader which looks up templates in the given directory. Templates that start with a dot (.) or are contained in a folder starting with a dot cannot be loaded.

ยงExample

fn create_env() -> Environment<'static> {
    let mut env = Environment::new();
    env.set_loader(path_loader("path/to/templates"));
    env
}