Skip to content

Commit dddd2fa

Browse files
author
matheo
committed
move syntaxt to <twig:
1 parent 002bebc commit dddd2fa

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/TwigComponent/src/Twig/TwigPreLexer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function preLexComponents(string $input): string
3636
$output = '';
3737

3838
while ($this->position < $this->length) {
39-
if ($this->consume('<t:')) {
39+
if ($this->consume('<twig:')) {
4040
$componentName = $this->consumeComponentName();
4141

4242
if ('block' === $componentName) {
@@ -67,16 +67,16 @@ public function preLexComponents(string $input): string
6767
continue;
6868
}
6969

70-
if (!empty($this->currentComponents) && $this->check('</t:')) {
71-
$this->consume('</t:');
70+
if (!empty($this->currentComponents) && $this->check('</twig:')) {
71+
$this->consume('</twig:');
7272
$closingComponentName = $this->consumeComponentName();
7373
$this->consume('>');
7474

7575
$lastComponent = array_pop($this->currentComponents);
7676
$lastComponentName = $lastComponent['name'];
7777

7878
if ($closingComponentName !== $lastComponentName) {
79-
throw new \RuntimeException("Expected closing tag '</t:{$lastComponentName}>' but found '</t:{$closingComponentName}>' at line {$this->line}");
79+
throw new \RuntimeException("Expected closing tag '</twig:{$lastComponentName}>' but found '</twig:{$closingComponentName}>' at line {$this->line}");
8080
}
8181

8282
// we've reached the end of this component. If we're inside the
@@ -109,7 +109,7 @@ public function preLexComponents(string $input): string
109109

110110
if (!empty($this->currentComponents)) {
111111
$lastComponent = array_pop($this->currentComponents)['name'];
112-
throw new \RuntimeException(sprintf('Expected closing tag "</t:%s>" not found at line %d.', $lastComponent, $this->line));
112+
throw new \RuntimeException(sprintf('Expected closing tag "</twig:%s>" not found at line %d.', $lastComponent, $this->line));
113113
}
114114

115115
return $output;
@@ -150,7 +150,7 @@ private function consumeAttributes(): string
150150

151151
$key = $this->consumeComponentName();
152152

153-
// <t:component someProp> -> someProp: true
153+
// <twig:component someProp> -> someProp: true
154154
if (!$this->check('=')) {
155155
$attributes[] = sprintf('%s: true', $key);
156156
$this->consumeWhitespace();
@@ -293,7 +293,7 @@ private function consumeBlock(): string
293293

294294
$output = "{% block {$blockName} %}";
295295

296-
$closingTag = '</t:block>';
296+
$closingTag = '</twig:block>';
297297
if (!$this->doesStringEventuallyExist($closingTag)) {
298298
throw new \RuntimeException("Expected closing tag '{$closingTag}' for block '{$blockName}' at line {$this->line}");
299299
}

src/TwigComponent/tests/Unit/TwigPreLexerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,47 @@ public function testPreLex(string $input, string $expectedOutput): void
2828
public function getLexTests(): iterable
2929
{
3030
yield 'simple_component' => [
31-
'<t:foo />',
31+
'<twig:foo />',
3232
'{% component foo %}{% endcomponent %}',
3333
];
3434

3535
yield 'component_with_attributes' => [
36-
'<t:foo bar="baz" with_quotes="It\'s with quotes" />',
36+
'<twig:foo bar="baz" with_quotes="It\'s with quotes" />',
3737
"{% component foo with { bar: 'baz', with_quotes: 'It\'s with quotes' } %}{% endcomponent %}",
3838
];
3939

4040
yield 'component_with_dynamic_attributes' => [
41-
'<t:foo dynamic="{{ dynamicVar }}" :otherDynamic="anotherVar" />',
41+
'<twig:foo dynamic="{{ dynamicVar }}" :otherDynamic="anotherVar" />',
4242
'{% component foo with { dynamic: dynamicVar, otherDynamic: anotherVar } %}{% endcomponent %}',
4343
];
4444

4545
yield 'component_with_closing_tag' => [
46-
'<t:foo></t:foo>',
46+
'<twig:foo></twig:foo>',
4747
'{% component foo %}{% endcomponent %}',
4848
];
4949

5050
yield 'component_with_block' => [
51-
'<t:foo><t:block name="foo_block">Foo</t:block></t:foo>',
51+
'<twig:foo><twig:block name="foo_block">Foo</twig:block></twig:foo>',
5252
'{% component foo %}{% block foo_block %}Foo{% endblock %}{% endcomponent %}',
5353
];
5454

5555
yield 'component_with_embedded_component_inside_block' => [
56-
'<t:foo><t:block name="foo_block"><t:bar /></t:block></t:foo>',
56+
'<twig:foo><twig:block name="foo_block"><twig:bar /></twig:block></twig:foo>',
5757
'{% component foo %}{% block foo_block %}{% component bar %}{% endcomponent %}{% endblock %}{% endcomponent %}',
5858
];
5959

6060
yield 'attribute_with_no_value' => [
61-
'<t:foo bar />',
61+
'<twig:foo bar />',
6262
'{% component foo with { bar: true } %}{% endcomponent %}',
6363
];
6464

6565
yield 'component_with_default_block_content' => [
66-
'<t:foo>Foo</t:foo>',
66+
'<twig:foo>Foo</twig:foo>',
6767
'{% component foo %}{% block content %}Foo{% endblock %}{% endcomponent %}',
6868
];
6969

7070
yield 'component_with_default_block_that_holds_a_component_and_multi_blocks' => [
71-
'<t:foo>Foo <t:bar /><t:block name="other_block">Other block</t:block></t:foo>',
71+
'<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
];
7474
}

0 commit comments

Comments
 (0)