diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-01-13 15:53:43 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-01-13 19:32:17 +0100 |
commit | 77a477e7d6a9e4f0302c003cab417d873e4f62fd (patch) | |
tree | 5c1b44356e358c33038706022966f827232a9722 /askama_shared | |
parent | 345f8432f51e2af7017915b35c203f723f2459d0 (diff) | |
download | askama-77a477e7d6a9e4f0302c003cab417d873e4f62fd.tar.gz askama-77a477e7d6a9e4f0302c003cab417d873e4f62fd.tar.bz2 askama-77a477e7d6a9e4f0302c003cab417d873e4f62fd.zip |
Tweak attribute parsing some more
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/input.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs index f1b2dc6..1d98231 100644 --- a/askama_shared/src/input.rs +++ b/askama_shared/src/input.rs @@ -36,16 +36,13 @@ impl TemplateInput<'_> { if template_args.is_some() { return Err(CompileError::Static("duplicated 'template' attribute")); } - let template = attr.parse_meta().map_err(|e| { - CompileError::String(format!("unable to parse attribute: {}", e)) - })?; - match template { - syn::Meta::List(inner) => template_args = Some(inner), - _ => { - return Err(CompileError::Static( - "attribute 'template' has incorrect type", - )); + + match attr.parse_meta() { + Ok(syn::Meta::List(syn::MetaList { nested, .. })) => { + template_args = Some(nested); } + Ok(_) => return Err("'template' attribute must be a list".into()), + Err(e) => return Err(format!("unable to parse attribute: {}", e).into()), } } } @@ -60,7 +57,7 @@ impl TemplateInput<'_> { let mut escaping = None; let mut ext = None; let mut syntax = None; - for item in template_args.nested { + for item in template_args { let pair = match item { syn::NestedMeta::Meta(syn::Meta::NameValue(ref pair)) => pair, _ => { |