aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-02 09:29:08 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-07-02 09:29:08 +0200
commit9021c229b72861e4b5fc49260819643eb92d8cb6 (patch)
treea7124b8e6b0c9d9e19ec5eebf6140788996be85f /askama_derive
parentec2e873d73a3f820fe301b682cb100d07f44994b (diff)
downloadaskama-9021c229b72861e4b5fc49260819643eb92d8cb6.tar.gz
askama-9021c229b72861e4b5fc49260819643eb92d8cb6.tar.bz2
askama-9021c229b72861e4b5fc49260819643eb92d8cb6.zip
Further improve matching source and ext in TemplateInput
Diffstat (limited to '')
-rw-r--r--askama_derive/src/input.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 93d5e17..2787084 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -85,17 +85,15 @@ impl<'a> TemplateInput<'a> {
}
let source = source.expect("template path or source not found in attributes");
- let path = match (&source, ext.is_some()) {
- (&Source::Path(_), true) => {
+ let path = match (&source, &ext) {
+ (&Source::Path(_), Some(_)) => {
panic!("'ext' attribute cannot be used with 'path' attribute")
}
- (&Source::Source(_), false) => {
+ (&Source::Source(_), None) => {
panic!("must include 'ext' attribute when using 'source' attribute")
}
- (&Source::Path(ref path), false) => path::find_template_from_path(path, None),
- (&Source::Source(_), true) => {
- PathBuf::from(format!("{}.{}", ast.ident, ext.as_ref().unwrap()))
- }
+ (&Source::Path(ref path), None) => path::find_template_from_path(path, None),
+ (&Source::Source(_), Some(ext)) => PathBuf::from(format!("{}.{}", ast.ident, ext)),
};
let parent = match ast.data {