aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-07 20:42:54 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2017-09-07 20:42:54 +0200
commit20803616dc3ecea0f770fb6a0e4b6eb73f598dd6 (patch)
treef11bca6e7328d2de3261a7578676258ef1e4ad79
parentee9db1dbf441b0fd17058b56d39a27abf9d3e517 (diff)
downloadaskama-20803616dc3ecea0f770fb6a0e4b6eb73f598dd6.tar.gz
askama-20803616dc3ecea0f770fb6a0e4b6eb73f598dd6.tar.bz2
askama-20803616dc3ecea0f770fb6a0e4b6eb73f598dd6.zip
Refactor creation of TemplateMeta value
Diffstat (limited to '')
-rw-r--r--askama_shared/src/input.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs
index 371cf6d..95233d3 100644
--- a/askama_shared/src/input.rs
+++ b/askama_shared/src/input.rs
@@ -99,21 +99,17 @@ impl<'a> TemplateMeta<'a> {
}
}
- match source {
- Some(s) => {
- match (&s, ext.is_some()) {
- (&Source::Path(_), true) => {
- panic!("'ext' attribute cannot be used with 'path' attribute")
- },
- (&Source::Source(_), false) => {
- panic!("must include 'ext' attribute when using 'source' attribute")
- },
- _ => {},
- }
- TemplateMeta { source: s, print, escaping, ext }
+ let source = source.expect("template path or source not found in attributes");
+ match (&source, ext.is_some()) {
+ (&Source::Path(_), true) => {
+ panic!("'ext' attribute cannot be used with 'path' attribute")
+ },
+ (&Source::Source(_), false) => {
+ panic!("must include 'ext' attribute when using 'source' attribute")
},
- None => panic!("template path or source not found in struct attributes"),
+ _ => {},
}
+ TemplateMeta { source, print, escaping, ext }
}
}