aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-30 17:04:30 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-08-30 22:54:32 +0200
commit726ca1cc3356f7aa59d7c2730c9f3b3588236cb0 (patch)
tree6ebdfeb9a0b4af290af3faa42b3a09abcb71440d /askama_shared/src/generator.rs
parented2e640dbdff88fe118d943fa0ea9ae00eb11555 (diff)
downloadaskama-726ca1cc3356f7aa59d7c2730c9f3b3588236cb0.tar.gz
askama-726ca1cc3356f7aa59d7c2730c9f3b3588236cb0.tar.bz2
askama-726ca1cc3356f7aa59d7c2730c9f3b3588236cb0.zip
Add {% break %} and {% continue %}
This PR adds `{% break %}` and `{% continue %}` statements to break out of a loop, or continue with the next element of the iterator.
Diffstat (limited to 'askama_shared/src/generator.rs')
-rw-r--r--askama_shared/src/generator.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index ec468e5..3bcb5d9 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -459,6 +459,16 @@ impl<'a, S: std::hash::BuildHasher> Generator<'a, S> {
// No whitespace handling: child template top-level is not used,
// except for the blocks defined in it.
}
+ Node::Break(ws) => {
+ self.handle_ws(ws);
+ self.write_buf_writable(buf)?;
+ buf.writeln("break;")?;
+ }
+ Node::Continue(ws) => {
+ self.handle_ws(ws);
+ self.write_buf_writable(buf)?;
+ buf.writeln("continue;")?;
+ }
}
}