Skip to content

Commit 6d1f7b9

Browse files
committed
Fix SubExpressions as PathExpression roots
1 parent cd9fcd2 commit 6d1f7b9

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Ast/MustacheStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MustacheStatement extends Statement
99
*/
1010
public function __construct(
1111
string $type,
12-
public PathExpression|Literal $path,
12+
public PathExpression|Literal|SubExpression $path,
1313
public array $params,
1414
public ?Hash $hash,
1515
public bool $escaped,

src/ParserAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ protected function prepareProgram(array $statements, ?SourceLocation $loc = null
553553
* @param Expression[] $params
554554
*/
555555
protected function prepareMustache(
556-
PathExpression|Literal $path,
556+
PathExpression|Literal|SubExpression $path,
557557
array $params,
558558
?Hash $hash,
559559
string $open,

tests/ParserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public static function successProvider(): array
4848
['{{te.[e.s[t].endP}}'],
4949
['{{te.[e[s.t].endQ}}'],
5050
['{{#with items}}OK!{{/with}}'],
51+
// SubExpression as PathExpression root
52+
// https://github.com/handlebars-lang/handlebars-parser/commit/1b9f38aba8761c67e3c824f22a6da6c82d7e3d79
53+
['{{(my-helper foo).bar}}'],
54+
['{{((my-helper foo).bar baz)}}'],
55+
['{{(foo (my-helper bar).baz)}}'],
56+
['{{(foo bar=(my-helper baz).qux)}}'],
5157
];
5258
}
5359

0 commit comments

Comments
 (0)