aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_shared/src/input.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs
index 25d61e1..a679461 100644
--- a/askama_shared/src/input.rs
+++ b/askama_shared/src/input.rs
@@ -193,11 +193,17 @@ impl TemplateInput<'_> {
})
}
+ #[inline]
pub fn extension(&self) -> Option<&str> {
- self.ext.as_deref().or_else(|| extension(&self.path))
+ ext_default_to_path(self.ext.as_deref(), &self.path)
}
}
+#[inline]
+pub fn ext_default_to_path<'a>(ext: Option<&'a str>, path: &'a Path) -> Option<&'a str> {
+ ext.or_else(|| extension(path))
+}
+
fn extension(path: &Path) -> Option<&str> {
let ext = path.extension().map(|s| s.to_str().unwrap())?;