aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/parser.rs
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-16 16:23:31 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-07-30 11:45:56 +0200
commit1622df7aeecb71fca2da630330513b26cefef16b (patch)
tree01348c855200790d9eb1a9bee01897d1e74f8604 /askama_shared/src/parser.rs
parent9e7fe8f2f9344d171800f98b556751d981ff9b17 (diff)
downloadaskama-1622df7aeecb71fca2da630330513b26cefef16b.tar.gz
askama-1622df7aeecb71fca2da630330513b26cefef16b.tar.bz2
askama-1622df7aeecb71fca2da630330513b26cefef16b.zip
Allow omitting "with" keyword in match blocks
Askama uses the syntax `{% when Variant with (parameters) %}` in `{% match %}` blocks. This is done because Askama does not implement the whole pattern matching of Rust's `match` statements. This PR wants to bring Askama a step closer Rust's matching, so the "with" keyword should not be needed anymore.
Diffstat (limited to '')
-rw-r--r--askama_shared/src/parser.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs
index d2b2cd1..29b325d 100644
--- a/askama_shared/src/parser.rs
+++ b/askama_shared/src/parser.rs
@@ -550,7 +550,7 @@ fn parameters(i: &[u8]) -> IResult<&[u8], Vec<&str>> {
fn with_parameters(i: &[u8]) -> IResult<&[u8], MatchParameters<'_>> {
let (i, (_, value)) = tuple((
- tag("with"),
+ opt(tag("with")),
alt((match_simple_parameters, match_named_parameters)),
))(i)?;
Ok((i, value))