Skip to content

Commit

Permalink
Fixed extension to ignore common jinja extensions (fixes #457)
Browse files Browse the repository at this point in the history
  • Loading branch information
vallentin committed Mar 10, 2021
1 parent 2b06170 commit 429fd07
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion askama_shared/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,17 @@ impl<'a> TemplateInput<'a> {
}

fn extension(path: &Path) -> Option<&str> {
path.extension().map(|s| s.to_str().unwrap())
let ext = path.extension().map(|s| s.to_str().unwrap())?;

const JINJA_EXTENSIONS: [&str; 3] = ["j2", "jinja", "jinja2"];
if JINJA_EXTENSIONS.contains(&ext) {
Path::new(path.file_stem().unwrap())
.extension()
.map(|s| s.to_str().unwrap())
.or(Some(ext))
} else {
Some(ext)
}
}

pub enum Source {
Expand Down

0 comments on commit 429fd07

Please sign in to comment.