Closed
Description
I have a component that accepts any HTML attribute in addition to other props:
{# templates/components/IconMini.html.twig #}
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
{{ attributes.defaults({
class: 'h-5 w-5',
}) }}
>
{# ... #}
</svg>
But if I pass hyphen-separated HTML attributes like aria-*
or data-*
, I get the following error: A hash key must be followed by a colon (:). Unexpected token "operator" of value "-" ("punctuation" expected with value ":").
{# templates/_navbar.html.twig #}
<twig:IconMini name="chevron-down" aria-hidden="true" />
The component syntax works fine:
{# templates/_navbar.html.twig #}
{{ component('IconMini', {
name: 'chevron-down',
'aria-hidden': 'true',
}) }}
Other than that, I absolutely love the new HTML Syntax!
Metadata
Metadata
Assignees
Labels
No labels