Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Setup HTML Escaping For Files With A Different Extension In Minijinja

This is a draft with just the code snippet.

More details coming when I can get to them.

rust
use minijinja::AutoEscape;

fn create_env(path: &str) -> Environment<'static> {
    let mut env = Environment::new();
    env.set_source(Source::from_path(path));
    env.set_auto_escape_callback(|name| {
    if matches!(name.rsplit('.').next().unwrap_or(""), "html" | "jinja") {
        AutoEscape::Html
    } else {
        AutoEscape::None
    }
});
    env
}