Oct 20, 2023
0
Level 4
Blade component attributes merge and curly brackets
This is my first post on this forum, despite my 6 yr membership, so hello everyone!
But to the point. Does anyone tries to merge Alpines x-data attribute using ComponentAttributeBag:merge() method? Like this:
<x-form.field {{ $attributes->merge([
'x-data' => '{type: \'password\', value: \'test\'}',
]) }}>
It seems, that the Blade compiler fails on this, because there are curly brackets inside the attribute value. Am I doing something wrong? I came up with a workaround, but it's ugly and I don't like it.
<x-form.field {{ $attributes->merge([
'x-data' => html_entity_decode('{type: \'password\', value: \'\'}'),
]) }}>
Is there a better way to do this? Or is this a bug?
Please or to participate in this conversation.