diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-01-12 16:06:27 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-01-12 16:06:42 +0100 |
commit | e69b76132070bae48317a886b0aef9e51e6ea00d (patch) | |
tree | 8869b458d33ab1729316e21c34f5c33d91f10f47 /askama_derive/src/generator.rs | |
parent | 8cc20486c752430a6da50f296e519843b00f61cb (diff) | |
download | askama-e69b76132070bae48317a886b0aef9e51e6ea00d.tar.gz askama-e69b76132070bae48317a886b0aef9e51e6ea00d.tar.bz2 askama-e69b76132070bae48317a886b0aef9e51e6ea00d.zip |
Flush buffer before exiting block with non-empty scope (fixes #227)
Diffstat (limited to 'askama_derive/src/generator.rs')
-rw-r--r-- | askama_derive/src/generator.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index c4315d0..f1e1174 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -751,6 +751,12 @@ impl<'a> Generator<'a> { self.prepare_ws(*ws1); self.locals.push(); let size_hint = self.handle(ctx, nodes, buf, AstLevel::Block); + + if !self.locals.is_current_empty() { + // Need to flush the buffer before popping the variable stack + self.write_buf_writable(buf); + } + self.locals.pop(); self.flush_ws(*ws2); @@ -1292,6 +1298,9 @@ where None => false, } } + fn is_current_empty(&self) -> bool { + self.scopes.last().unwrap().is_empty() + } fn insert(&mut self, val: T) { self.scopes.last_mut().unwrap().insert(val); } |