Skip to content

Commit

Permalink
Re-add {% set %} as alias for {% let %}
Browse files Browse the repository at this point in the history
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]: <615fb82>
  • Loading branch information
Kijewski committed May 18, 2024
1 parent 38a2a86 commit a86e1d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion askama_parser/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
12 changes: 12 additions & 0 deletions askama_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}

0 comments on commit a86e1d6

Please sign in to comment.