diff options
author | René Kijewski <kijewski@library.vetmed.fu-berlin.de> | 2021-07-16 16:14:30 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-07-30 11:45:56 +0200 |
commit | 9e7fe8f2f9344d171800f98b556751d981ff9b17 (patch) | |
tree | ac858280756ddb44ca7ef168b10f4ac71b700927 /testing/tests | |
parent | 136e55c8cfab6e058e6a734cc8193706c95553e9 (diff) | |
download | askama-9e7fe8f2f9344d171800f98b556751d981ff9b17.tar.gz askama-9e7fe8f2f9344d171800f98b556751d981ff9b17.tar.bz2 askama-9e7fe8f2f9344d171800f98b556751d981ff9b17.zip |
Allow using "with" keyword in "let" statements
Askama uses the syntax `{% when Variant with (parameters) %}` in
`{% match %}` blocks.
This change allows the optional use of the keyword "with" in "let" and
"if let" statements, too.
Diffstat (limited to '')
-rw-r--r-- | testing/tests/let_destructoring.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testing/tests/let_destructoring.rs b/testing/tests/let_destructoring.rs index 20f7fff..5cb7ae4 100644 --- a/testing/tests/let_destructoring.rs +++ b/testing/tests/let_destructoring.rs @@ -105,3 +105,17 @@ fn test_let_destruct_with_path() { }; assert_eq!(t.render().unwrap(), "hello"); } + +#[derive(Template)] +#[template(source = "{% let some::path::Struct with (v) = v %}{{v}}", ext = "txt")] +struct LetDestructoringWithPathAndWithKeyword<'a> { + v: some::path::Struct<'a>, +} + +#[test] +fn test_let_destruct_with_path_and_with_keyword() { + let t = LetDestructoringWithPathAndWithKeyword { + v: some::path::Struct("hello"), + }; + assert_eq!(t.render().unwrap(), "hello"); +} |