diff options
author | Christian Vallentin <mail@vallentin.dev> | 2020-12-03 21:48:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 21:48:14 +0100 |
commit | 5b01e605914a49f0b9e71e7dbe7c17ef1de2c522 (patch) | |
tree | d90bda1fa1ad6199b2f78969cdbba083139c02bb /askama_shared/src/generator.rs | |
parent | 810d5ad5067085cc5e4be19903b5804b1ff13430 (diff) | |
download | askama-5b01e605914a49f0b9e71e7dbe7c17ef1de2c522.tar.gz askama-5b01e605914a49f0b9e71e7dbe7c17ef1de2c522.tar.bz2 askama-5b01e605914a49f0b9e71e7dbe7c17ef1de2c522.zip |
Fixed whitespace issue when generating if statement (#394)
* Fixed #377
Diffstat (limited to '')
-rw-r--r-- | askama_shared/src/generator.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs index ad086a3..6a185c1 100644 --- a/askama_shared/src/generator.rs +++ b/askama_shared/src/generator.rs @@ -505,8 +505,9 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { let mut has_else = false; for (i, &(cws, ref cond, ref nodes)) in conds.iter().enumerate() { self.handle_ws(cws); - if arm_sizes.is_empty() { - flushed += self.write_buf_writable(buf)?; + flushed += self.write_buf_writable(buf)?; + if i > 0 { + self.locals.pop(); } let mut arm_size = 0; @@ -539,14 +540,14 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> { self.locals.push(); arm_size += self.handle(ctx, nodes, buf, AstLevel::Nested)?; - arm_size += self.write_buf_writable(buf)?; arm_sizes.push(arm_size); - - self.locals.pop(); } self.handle_ws(ws); + flushed += self.write_buf_writable(buf)?; buf.writeln("}")?; + self.locals.pop(); + if !has_else { arm_sizes.push(0); } |