aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'askama_shared/src/input.rs')
-rw-r--r--askama_shared/src/input.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs
index 59f1303..be380ea 100644
--- a/askama_shared/src/input.rs
+++ b/askama_shared/src/input.rs
@@ -1,6 +1,6 @@
use crate::{CompileError, Config, Syntax};
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::str::FromStr;
use quote::ToTokens;
@@ -198,6 +198,14 @@ impl<'a> TemplateInput<'a> {
path,
})
}
+
+ pub fn extension(&self) -> Option<&str> {
+ extension(&self.path)
+ }
+}
+
+fn extension(path: &Path) -> Option<&str> {
+ path.extension().map(|s| s.to_str().unwrap())
}
pub enum Source {