Skip to content

Commit 776c4c0

Browse files
committed
tag name can end with ? like {foo?}
1 parent 001de2d commit 776c4c0

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Latte/Compiler/TemplateLexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function stateLatteTag(): array
9494
{
9595
$tokens[] = $this->match('~
9696
(?<Slash>/)?
97-
(?<Latte_Name> = | _(?!_) | [a-z]\w*+(?:[.:-]\w+)*+(?!::|\(|\\\))? # name, /name, but not function( or class:: or namespace\
97+
(?<Latte_Name> = | _(?!_) | [a-z]\w*+(?:[.:-]\w+)*+\??(?!::|\(|\\\))? # name, /name, but not function( or class:: or namespace\
9898
~xsiAu');
9999

100100
$tokens[] = $this->tagLexer->tokenizePartially($this->input, $this->position);

tests/common/Compiler.samples.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,11 @@ Assert::contains(
103103
'escapeHtmlText(My\Class::foo)',
104104
$latte->compile('{My\Class::foo}'),
105105
);
106+
107+
108+
// allowed ? in name
109+
Assert::exception(
110+
fn() => $latte->compile('{foo?}'),
111+
Latte\CompileException::class,
112+
'Unexpected tag {foo?} (on line 1 at column 1)',
113+
);

0 commit comments

Comments
 (0)