From 7da4ad54ebbb529c9b43ed545f0f1de8341bca50 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 2 Jun 2020 23:25:30 +0200 Subject: Allow block definitions in if/for/match blocks (fixes #335) --- askama_shared/src/generator.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'askama_shared/src/generator.rs') diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index fe02b8a..36ac55e 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -363,15 +363,7 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { self.write_loop(ctx, buf, ws1, var, iter, body, ws2); } Node::BlockDef(ws1, name, _, ws2) => { - if AstLevel::Nested == level { - panic!( - "blocks ('{}') are only allowed at the top level of a template \ - or another block", - name - ); - } - let outer = WS(ws1.0, ws2.1); - self.write_block(buf, Some(name), outer); + self.write_block(buf, Some(name), WS(ws1.0, ws2.1)); } Node::Include(ws, path) => { size_hint += self.handle_include(ctx, buf, ws, path); -- cgit