From a86e1d655b957ff39d8eb3c3dc4bb0959b98d4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Sat, 18 May 2024 05:07:27 +0200 Subject: [PATCH] Re-add `{% set %}` as alias for `{% let %}` Commit [615fb82] introduced a regression. `{% set %}` and `{% let %}` should be interchangeable, but only the latter syntax works. This PR fixes the problem, and adds a regression test. [615fb82]: --- askama_parser/src/node.rs | 2 +- askama_parser/src/tests.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/askama_parser/src/node.rs b/askama_parser/src/node.rs index 408a8000..1552a572 100644 --- a/askama_parser/src/node.rs +++ b/askama_parser/src/node.rs @@ -69,7 +69,7 @@ impl<'a> Node<'a> { let func = match tag { "call" => |i, s| wrap(Self::Call, Call::parse(i, s)), - "let" => |i, s| wrap(Self::Let, Let::parse(i, s)), + "let" | "set" => |i, s| wrap(Self::Let, Let::parse(i, s)), "if" => |i, s| wrap(Self::If, If::parse(i, s)), "for" => |i, s| wrap(|n| Self::Loop(Box::new(n)), Loop::parse(i, s)), "match" => |i, s| wrap(Self::Match, Match::parse(i, s)), diff --git a/askama_parser/src/tests.rs b/askama_parser/src/tests.rs index 3e7f8caa..3035c080 100644 --- a/askama_parser/src/tests.rs +++ b/askama_parser/src/tests.rs @@ -932,3 +932,15 @@ fn fuzzed_comment_depth() { .expect("timeout"); test.join().unwrap(); } + +#[test] +fn let_set() { + assert_eq!( + Ast::from_str("{% let a %}", None, &Syntax::default()) + .unwrap() + .nodes(), + Ast::from_str("{% set a %}", None, &Syntax::default()) + .unwrap() + .nodes(), + ); +}