-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TwigComponent] Support ...spread operator with html syntax #1023
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,5 +216,31 @@ public function getLexTests(): iterable | |
'{% verbatim %}<twig:Alert/>{% endverbatim %}', | ||
'{% verbatim %}<twig:Alert/>{% endverbatim %}', | ||
]; | ||
|
||
yield 'component_attr_spreading_self_closing' => [ | ||
'<twig:foobar bar="baz"{{...attr}}/>', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of having ... between {{ why not just do: <twig:foobar bar="baz" ...attr /> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me eyes it's easier to find that it's a variable like in twig There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A little funky looking but what about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My proposed solution is already in our prod and working, so I'd prefer as is 😁 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at React: <button className={className} {...other} /> And Vue:
Given these, the logical options are:
And that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that JSX for Vue.js also use
|
||
'{{ component(\'foobar\', { bar: \'baz\', ...attr }) }}', | ||
]; | ||
yield 'component_attr_spreading_self_closing2' => [ | ||
'<twig:foobar bar="baz"{{ ...customAttrs }} />', | ||
'{{ component(\'foobar\', { bar: \'baz\', ...customAttrs }) }}', | ||
]; | ||
yield 'component_attr_spreading_self_closing3' => [ | ||
'<twig:foobar bar="baz" {{...attr }} />', | ||
'{{ component(\'foobar\', { bar: \'baz\', ...attr }) }}', | ||
]; | ||
|
||
yield 'component_attr_spreading_with_content1' => [ | ||
'<twig:foobar bar="baz"{{...attr}}>content</twig:foobar>', | ||
'{% component \'foobar\' with { bar: \'baz\', ...attr } %}{% block content %}content{% endblock %}{% endcomponent %}', | ||
]; | ||
yield 'component_attr_spreading_with_content2' => [ | ||
'<twig:foobar bar="baz"{{ ...customAttrs }}>content</twig:foobar>', | ||
'{% component \'foobar\' with { bar: \'baz\', ...customAttrs } %}{% block content %}content{% endblock %}{% endcomponent %}', | ||
]; | ||
yield 'component_attr_spreading_with_content3' => [ | ||
'<twig:foobar bar="baz" {{ ...attr }}>content</twig:foobar>', | ||
'{% component \'foobar\' with { bar: \'baz\', ...attr } %}{% block content %}content{% endblock %}{% endcomponent %}', | ||
]; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should consume the whitespace before doing this check, tab, or multiples tab can be valid syntax too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is consumed 4 lines before, isn't it?