DEV Community

Discussion on: Sharing data from Laravel components to Alpine

Collapse
 
kondratovbr profile image
Bogdan Kondratov • Edited

Doesn't exactly work if your data ends with an array or an object - it trims ALL curly brackets from the end but it should only remove the last one. So, some ifs with some substr would actually be better.

But nice snippet nevertheless.

Upd.: It also need to trim spaces from extracted variable names. Like this for example:

fn (\$variable) => str_replace('$', '', trim(\$variable, ' '))

Otherwise the spaces are kept as part of the keys breaking everything.

Collapse
 
felixdorn profile image
Félix Dorn

I've actually caught this bug a week ago and forgot to update the snippet! Good catch!