diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-16 14:06:50 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2018-06-16 14:06:50 +0200 |
commit | 316b28600d8af30b8af5d552b5f3b466a0ad7c22 (patch) | |
tree | 0f13180926f1c3d1f71d18b0e636349cc9fd5b76 /askama_derive/src/generator.rs | |
parent | dbb48dbbf2647100f6e3db5d4ae0ec920722eca4 (diff) | |
download | askama-316b28600d8af30b8af5d552b5f3b466a0ad7c22.tar.gz askama-316b28600d8af30b8af5d552b5f3b466a0ad7c22.tar.bz2 askama-316b28600d8af30b8af5d552b5f3b466a0ad7c22.zip |
Restrict use of macro/import/extend nodes to the top level
Diffstat (limited to '')
-rw-r--r-- | askama_derive/src/generator.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 0d3dd5f..a6e74bc 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -358,20 +358,20 @@ impl<'a> Generator<'a> { self.write_call(state, ws, scope, name, args); }, Node::Macro(_, ref m) => { - if let AstLevel::Nested = level { + if level != AstLevel::Top { panic!("macro blocks only allowed at the top level"); } self.flush_ws(&m.ws1); self.prepare_ws(&m.ws2); }, Node::Import(ref ws, _, _) => { - if let AstLevel::Nested = level { + if level != AstLevel::Top { panic!("import blocks only allowed at the top level"); } self.handle_ws(ws); }, Node::Extends(_) => { - if let AstLevel::Nested = level { + if level != AstLevel::Top { panic!("extend blocks only allowed at the top level"); } // No whitespace handling: child template top-level is not used, @@ -974,7 +974,7 @@ fn get_parent_type(ast: &syn::DeriveInput) -> Option<&syn::Type> { }.next() } -#[derive(Clone)] +#[derive(Clone, PartialEq)] enum AstLevel { Top, Block, |