Skip to content

Commit 1d37aa6

Browse files
author
matheo
committed
add more special characters
1 parent 2acecac commit 1d37aa6

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/TwigComponent/src/Twig/TwigPreLexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function preLexComponents(string $input): string
117117
private function consumeComponentName(): string
118118
{
119119
$start = $this->position;
120-
while ($this->position < $this->length && preg_match('/[A-Za-z0-9_:]/', $this->input[$this->position])) {
120+
while ($this->position < $this->length && preg_match('/[A-Za-z0-9_:@\-\/.]/', $this->input[$this->position])) {
121121
++$this->position;
122122
}
123123
$componentName = substr($this->input, $start, $this->position - $start);

src/TwigComponent/tests/Unit/TwigPreLexerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,25 @@ public function getLexTests(): iterable
7171
'<twig:foo>Foo <twig:bar /><twig:block name="other_block">Other block</twig:block></twig:foo>',
7272
'{% component \'foo\' %}{% block content %}Foo {% component \'bar\' %}{% endcomponent %}{% endblock %}{% block other_block %}Other block{% endblock %}{% endcomponent %}',
7373
];
74+
yield 'component_with_character_:_on_his_name' => [
75+
'<twig:foo:bar></twig:foo:bar>',
76+
'{% component \'foo:bar\' %}{% endcomponent %}',
77+
];
78+
yield 'component_with_character_@_on_his_name' => [
79+
'<twig:@foo></twig:@foo>',
80+
'{% component \'@foo\' %}{% endcomponent %}',
81+
];
82+
yield 'component_with_character_-_on_his_name' => [
83+
'<twig:foo-bar></twig:foo-bar>',
84+
'{% component \'foo-bar\' %}{% endcomponent %}',
85+
];
86+
yield 'component_with_character_/_on_his_name' => [
87+
'<twig:foo/bar></twig:foo/bar>',
88+
'{% component \'foo/bar\' %}{% endcomponent %}',
89+
];
90+
yield 'component_with_character_._on_his_name' => [
91+
'<twig:foo.bar></twig:foo.bar>',
92+
'{% component \'foo.bar\' %}{% endcomponent %}',
93+
];
7494
}
7595
}

0 commit comments

Comments
 (0)