pub fn path_loader<'x, P: AsRef<Path> + 'x>(
dir: P,
) -> impl for<'a> Fn(&'a str) -> Result<Option<String>, Error> + Send + Sync + 'static
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
}