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.
Code
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
}