Closed barbieswimcrew closed 5 months ago
Looks legit to me! WDYT @kbond should attributes.render()
always return a string? Or is there a better solution?
Three options here:
attributes.render()
always return a string - this would still work with |default()
but would break ??
CVA:apply()
accept ?string ...$classes
and filter out null/empty strings(2) is the safest and could help in general (imagine a completely different twig call that returns string|null
)
Just made a PR for the solution 2. I think it's way much easier like that. Tell me what you think 😁
Yep, easiest fix for sure!
Hey guys, curious as I am, I just wanted to try out CVA. However, I'm running into problems:
That error happens when trying out CVA as documented here: https://symfony.com/bundles/ux-twig-component/current/index.html#component-with-complex-variants-cva
The error happens when I use and do not define any CSS classes. So, to me it looks like
attributes.render('class')
does not return an empty string but null. Am I doing something wrong or is the documentation incorrect?{{ alert.apply({color, size}, attributes.render('class')|format) }}
fixes the issue temporarily by casting the null to an empty string.