aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_shared/src/input.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs
index be380ea..febd51c 100644
--- a/askama_shared/src/input.rs
+++ b/askama_shared/src/input.rs
@@ -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 {