giorgiopogliani / twig-components

Twig components inspired from blade components
MIT License
71 stars 16 forks source link

Fix attributes echo for component in component #15

Closed Pindagus closed 2 years ago

Pindagus commented 2 years ago

button.twig:

<button {{ attributes.merge({ class: 'defaultClass' }) }}>{{ slot }}</button>

button/red.twig:

<x-button {{ attributes.merge({ class: 'bg-red-500' }) }}>{{ slot }}</x-button>

With the templates above the usage of <x-button.red class="mb-5">Click me</x-button.red> would fail. Some changes to the regex in ComponentTagCompiler fixes that.

giorgiopogliani commented 2 years ago

Nice!