From 726ca1cc3356f7aa59d7c2730c9f3b3588236cb0 Mon Sep 17 00:00:00 2001 From: René Kijewski Date: Fri, 30 Jul 2021 17:04:30 +0200 Subject: 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. --- askama_shared/src/generator.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'askama_shared/src/generator.rs') 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;")?; + } } } -- cgit