aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-22 14:59:56 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-22 14:59:56 +0100
commit8a25a1ee65031a687ad7d208eaa2843aed6c9752 (patch)
tree83e16e2662a3182ea94989d436e9752d2ca54bdb /askama_derive/src/generator.rs
parented98793b506c66723c713991f40c0065557a35d5 (diff)
downloadaskama-8a25a1ee65031a687ad7d208eaa2843aed6c9752.tar.gz
askama-8a25a1ee65031a687ad7d208eaa2843aed6c9752.tar.bz2
askama-8a25a1ee65031a687ad7d208eaa2843aed6c9752.zip
Add Template method to return template extension
Thanks to Ryan McGrath for the suggestion and initial implementation.
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r--askama_derive/src/generator.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index 5af38c0..db9ac17 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -117,6 +117,11 @@ impl<'a> Generator<'a> {
self.flush_ws(WS(false, false));
self.writeln("Ok(())");
self.writeln("}");
+
+ self.writeln("fn extension(&self) -> Option<&str> {");
+ self.writeln(&format!("{:?}", self.input.path.extension().map(|s| s.to_str().unwrap())));
+ self.writeln("}");
+
self.writeln("}");
}