diff options
author | vallentin <mail@vallentin.dev> | 2021-03-09 06:40:52 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-03-10 13:09:56 +0100 |
commit | d6c05d8eb97389a86780cc1c718eb2fd1ada6c6f (patch) | |
tree | 50eefa9c9fe07490b7cb635258ec15d582a991ff /askama_shared | |
parent | 606c68dd34d3ffd33e53c7d85ba2051ce24d5e1c (diff) | |
download | askama-d6c05d8eb97389a86780cc1c718eb2fd1ada6c6f.tar.gz askama-d6c05d8eb97389a86780cc1c718eb2fd1ada6c6f.tar.bz2 askama-d6c05d8eb97389a86780cc1c718eb2fd1ada6c6f.zip |
Changed to allow both path and ext
Diffstat (limited to 'askama_shared')
-rw-r--r-- | askama_shared/src/input.rs | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs index a0704aa..8986fea 100644 --- a/askama_shared/src/input.rs +++ b/askama_shared/src/input.rs @@ -124,11 +124,8 @@ impl<'a> TemplateInput<'a> { // of `ext` is merged into a synthetic `path` value here. let source = source.expect("template path or source not found in attributes"); let path = match (&source, &ext) { - (&Source::Path(ref path), None) => config.find_template(path, None)?, + (&Source::Path(ref path), _) => config.find_template(path, None)?, (&Source::Source(_), Some(ext)) => PathBuf::from(format!("{}.{}", ast.ident, ext)), - (&Source::Path(_), Some(_)) => { - return Err("'ext' attribute cannot be used with 'path' attribute".into()) - } (&Source::Source(_), None) => { return Err("must include 'ext' attribute when using 'source' attribute".into()) } @@ -200,7 +197,7 @@ impl<'a> TemplateInput<'a> { } pub fn extension(&self) -> Option<&str> { - extension(&self.path) + self.ext.as_deref().or_else(|| extension(&self.path)) } } |