@@ -29,17 +29,17 @@ public function getLexTests(): iterable
29
29
{
30
30
yield 'simple_component ' => [
31
31
'<twig:foo /> ' ,
32
- '{{ component( \'foo \') } } ' ,
32
+ '{% twig_component \'foo \' %}{% end_twig_component % } ' ,
33
33
];
34
34
35
35
yield 'component_with_attributes ' => [
36
36
'<twig:foo bar="baz" with_quotes="It \'s with quotes" /> ' ,
37
- "{{ component( 'foo', { bar: 'baz', with_quotes: 'It\'s with quotes' }) } } " ,
37
+ "{% twig_component 'foo' with { bar: 'baz', with_quotes: 'It\'s with quotes' } %}{% end_twig_component % } " ,
38
38
];
39
39
40
40
yield 'component_with_dynamic_attributes ' => [
41
41
'<twig:foo dynamic="{{ dynamicVar }}" :otherDynamic="anotherVar" /> ' ,
42
- '{{ component( \'foo \', { dynamic: (dynamicVar), otherDynamic: anotherVar }) } } ' ,
42
+ '{% twig_component \'foo \' with { dynamic: (dynamicVar), otherDynamic: anotherVar } %}{% end_twig_component % } ' ,
43
43
];
44
44
45
45
yield 'component_with_closing_tag ' => [
@@ -54,27 +54,27 @@ public function getLexTests(): iterable
54
54
55
55
yield 'component_with_traditional_block ' => [
56
56
'<twig:foo>{% block foo_block %}Foo{% endblock %}</twig:foo> ' ,
57
- '{% component \'foo \' %}{% block foo_block %}Foo{% endblock %}{% endcomponent %} ' ,
57
+ '{% twig_component \'foo \' %}{% block foo_block %}Foo{% endblock %}{% end_twig_component %} ' ,
58
58
];
59
59
60
60
yield 'traditional_blocks_around_component_do_not_confuse ' => [
61
61
'Hello {% block foo_block %}Foo{% endblock %}<twig:foo />{% block bar_block %}Bar{% endblock %} ' ,
62
- 'Hello {% block foo_block %}Foo{% endblock %}{{ component( \'foo \') } }{% block bar_block %}Bar{% endblock %} ' ,
62
+ 'Hello {% block foo_block %}Foo{% endblock %}{% twig_component \'foo \' %}{% end_twig_component % }{% block bar_block %}Bar{% endblock %} ' ,
63
63
];
64
64
65
65
yield 'component_with_embedded_component_inside_block ' => [
66
66
'<twig:foo><twig:slot name="foo_block"><twig:bar /></twig:slot></twig:foo> ' ,
67
- '{% twig_component \'foo \' %}{% slot foo_block %}{{ component( \'bar \') } }{% endslot %}{% end_twig_component %} ' ,
67
+ '{% twig_component \'foo \' %}{% slot foo_block %}{% twig_component \'bar \' %}{% end_twig_component % }{% endslot %}{% end_twig_component %} ' ,
68
68
];
69
69
70
70
yield 'attribute_with_no_value ' => [
71
71
'<twig:foo bar /> ' ,
72
- '{{ component( \'foo \', { bar: true }) } } ' ,
72
+ '{% twig_component \'foo \' with { bar: true } %}{% end_twig_component % } ' ,
73
73
];
74
74
75
75
yield 'attribute_with_no_value_and_no_attributes ' => [
76
76
'<twig:foo/> ' ,
77
- '{{ component( \'foo \') } } ' ,
77
+ '{% twig_component \'foo \' %}{% end_twig_component % } ' ,
78
78
];
79
79
80
80
yield 'component_with_default_block_content ' => [
@@ -84,7 +84,7 @@ public function getLexTests(): iterable
84
84
85
85
yield 'component_with_default_block_that_holds_a_component_and_multi_blocks ' => [
86
86
'<twig:foo>Foo <twig:bar /><twig:slot name="other_block">Other block</twig:slot></twig:foo> ' ,
87
- '{% twig_component \'foo \' %}Foo {{ component( \'bar \') } }{% slot other_block %}Other block{% endslot %}{% end_twig_component %} ' ,
87
+ '{% twig_component \'foo \' %}Foo {% twig_component \'bar \' %}{% end_twig_component % }{% slot other_block %}Other block{% endslot %}{% end_twig_component %} ' ,
88
88
];
89
89
yield 'component_with_character_:_on_his_name ' => [
90
90
'<twig:foo:bar></twig:foo:bar> ' ,
@@ -108,19 +108,19 @@ public function getLexTests(): iterable
108
108
];
109
109
yield 'component_with_mixture_of_string_and_twig_in_argument ' => [
110
110
'<twig:foo text="Hello {{ name }}!"/> ' ,
111
- "{{ component( 'foo', { text: 'Hello '~(name)~'!' }) } } " ,
111
+ "{% twig_component 'foo' with { text: 'Hello '~(name)~'!' } %}{% end_twig_component % } " ,
112
112
];
113
113
yield 'component_with_mixture_of_dynamic_twig_from_start ' => [
114
114
'<twig:foo text="{{ name }} is my name{{ ending~ \'!! \' }}"/> ' ,
115
- "{{ component( 'foo', { text: (name)~' is my name'~(ending~'!!') }) } } " ,
115
+ "{% twig_component 'foo' with { text: (name)~' is my name'~(ending~'!!') } %}{% end_twig_component % } " ,
116
116
];
117
117
yield 'dynamic_attribute_with_quotation_included ' => [
118
118
'<twig:foo text="{{ "hello!" }}"/> ' ,
119
- "{{ component( 'foo', { text: ( \"hello! \") }) } } " ,
119
+ "{% twig_component 'foo' with { text: ( \"hello! \") } %}{% end_twig_component % } " ,
120
120
];
121
121
yield 'component_with_mixture_of_string_and_twig_with_quote_in_argument ' => [
122
122
'<twig:foo text="Hello {{ name }}, I \'m Theo!"/> ' ,
123
- "{{ component( 'foo', { text: 'Hello '~(name)~', I\'m Theo!' }) } } " ,
123
+ "{% twig_component 'foo' with { text: 'Hello '~(name)~', I\'m Theo!' } %}{% end_twig_component % } " ,
124
124
];
125
125
yield 'component_where_entire_default_block_is_embedded_component ' => [
126
126
<<<EOF
@@ -129,9 +129,9 @@ public function getLexTests(): iterable
129
129
</twig:foo>
130
130
EOF ,
131
131
<<<EOF
132
- {% component 'foo' %}
133
- {% block content %}{% component 'bar' %}{% block content %} bar content{% endblock %}{% endcomponent %}
134
- {% endblock %}{% endcomponent %}
132
+ {% twig_component 'foo' %}
133
+ {% twig_component 'bar' %}bar content{% end_twig_component %}
134
+ {% end_twig_component %}
135
135
EOF
136
136
];
137
137
yield 'component_where_entire_default_block_is_embedded_component_self_closing ' => [
@@ -141,9 +141,9 @@ public function getLexTests(): iterable
141
141
</twig:foo>
142
142
EOF ,
143
143
<<<EOF
144
- {% component 'foo' %}
145
- {% block content %}{{ component('bar') } }
146
- {% endblock %}{% endcomponent %}
144
+ {% twig_component 'foo' %}
145
+ {% twig_component 'bar' %}{% end_twig_component % }
146
+ {% end_twig_component %}
147
147
EOF
148
148
];
149
149
@@ -155,36 +155,36 @@ public function getLexTests(): iterable
155
155
]" />
156
156
EOF ,
157
157
<<<EOF
158
- {{ component( 'TabbedCodeBlocks', { files: [
158
+ {% twig_component 'TabbedCodeBlocks' with { files: [
159
159
'src/Twig/MealPlanner.php',
160
160
'templates/components/MealPlanner.html.twig',
161
- ] }) } }
161
+ ] } %}{% end_twig_component % }
162
162
EOF
163
163
];
164
164
165
165
yield 'component_with_dashed_attribute ' => [
166
166
'<twig:foobar data-action="foo#bar"></twig:foobar> ' ,
167
- '{% component \'foobar \' with { \'data-action \': \'foo#bar \' } %}{% endcomponent %} ' ,
167
+ '{% twig_component \'foobar \' with { \'data-action \': \'foo#bar \' } %}{% end_twig_component %} ' ,
168
168
];
169
169
170
170
yield 'component_with_dashed_attribute_self_closing ' => [
171
171
'<twig:foobar data-action="foo#bar" /> ' ,
172
- '{{ component( \'foobar \', { \'data-action \': \'foo#bar \' }) } } ' ,
172
+ '{% twig_component \'foobar \' with { \'data-action \': \'foo#bar \' } %}{% end_twig_component % } ' ,
173
173
];
174
174
175
175
yield 'component_with_colon_attribute ' => [
176
176
'<twig:foobar my:attribute="yo"></twig:foobar> ' ,
177
- '{% component \'foobar \' with { \'my:attribute \': \'yo \' } %}{% endcomponent %} ' ,
177
+ '{% twig_component \'foobar \' with { \'my:attribute \': \'yo \' } %}{% end_twig_component %} ' ,
178
178
];
179
179
180
180
yield 'component_with_truthy_attribute ' => [
181
181
'<twig:foobar data-turbo-stream></twig:foobar> ' ,
182
- '{% component \'foobar \' with { \'data-turbo-stream \': true } %}{% endcomponent %} ' ,
182
+ '{% twig_component \'foobar \' with { \'data-turbo-stream \': true } %}{% end_twig_component %} ' ,
183
183
];
184
184
185
185
yield 'ignore_twig_comment ' => [
186
186
'{# <twig:Alert/> #} <twig:Alert/> ' ,
187
- '{# <twig:Alert/> #} {{ component( \'Alert \') } } ' ,
187
+ '{# <twig:Alert/> #} {% twig_component \'Alert \' %}{% end_twig_component % } ' ,
188
188
];
189
189
190
190
yield 'file_ended_with_comments ' => [
@@ -194,7 +194,7 @@ public function getLexTests(): iterable
194
194
195
195
yield 'mixing_component_and_file_ended_with_comments ' => [
196
196
'<twig:Alert/> {# <twig:Alert/> #} ' ,
197
- '{{ component( \'Alert \') } } {# <twig:Alert/> #} ' ,
197
+ '{% twig_component \'Alert \' %}{% end_twig_component % } {# <twig:Alert/> #} ' ,
198
198
];
199
199
}
200
200
}
0 commit comments