From ee9db1dbf441b0fd17058b56d39a27abf9d3e517 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 7 Sep 2017 20:42:54 +0200 Subject: Make ext attribute mandatory for source-specified templates --- askama_shared/src/input.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'askama_shared/src') diff --git a/askama_shared/src/input.rs b/askama_shared/src/input.rs index 7d27eb3..371cf6d 100644 --- a/askama_shared/src/input.rs +++ b/askama_shared/src/input.rs @@ -101,10 +101,14 @@ impl<'a> TemplateMeta<'a> { match source { Some(s) => { - if let Source::Path(_) = s { - if ext.is_some() { - panic!("'ext' attribute cannot be used with 'path' attribute"); - } + 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 } }, -- cgit