Laravel cuts off generating @json in the blade mid-air #49134
-
Laravel Versionv10.30.1 PHP Version8.2.12 Database Driver & Versionpostgres 14.5 DescriptionInn a nlade, when using
The generation stops in the mid of the json parsing, outputing just
and i get this error While doing it via json_encode directly works correctly
I have found these bug reports saying it should already be fixed with ymfony/http-foundation 6.1.1 but mine is 6.3.7 and i still get this error Steps To Reproducecontroller
view
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's not a good idea to use the blade directives like this - they are built using a basic Regex, and can't handle complex structures. Even the escaping brackets ( I'd recommend setting your array in a variable in your controller or a
|
Beta Was this translation helpful? Give feedback.
It's not a good idea to use the blade directives like this - they are built using a basic Regex, and can't handle complex structures. Even the escaping brackets (
{{ ... }}
) is regex based and not recommended for multi-line or super complex expressions.I'd recommend setting your array in a variable in your controller or a
<?php ... ?>
section at the start of your template and then rendering that variable using theJS
facade: https://laravel.com/docs/10.x/blade#rendering-json