From d6c05d8eb97389a86780cc1c718eb2fd1ada6c6f Mon Sep 17 00:00:00 2001 From: vallentin Date: Tue, 9 Mar 2021 06:40:52 +0100 Subject: Changed to allow both path and ext --- askama_shared/src/input.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'askama_shared/src/input.rs') 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)) } } -- cgit