I have a collection of objects that have been retrieved from a model called Persona
. Among the properties there is one called nombre
. In the controller I precede it with four "hard" spaces (
), because I need it indented in the view. I have always been told that it is better to process the data in the controller as much as possible, and avoid, if possible, manipulating it in the view, that the view should limit itself to showing what comes from the controller.
When I get to the view, I try to display that property, like so:
{{ $persona->nombre }}
The problem is that Blade replaces me &
with . Result: Instead of getting four leading spaces, I get on screen . How can I make the view show me the spaces correctly? If in the controller I use "regular" spaces, we already know that HTML ignores them, so the indentation is not shown, so I have to use hard spaces, but I need the view to display them as such, not as the literal of the entities.
&
Pedro
Pedro
From what I see, the problem comes from Blade displaying the interpolated data using the helper e()
, which incorporates the htmlspecialchars
PHP function. What would be the best way to display the data "as it comes", without that helper getting in the way? I'm sure there has to be some function or helper, but I've been looking at the documentation for hours and I don't see anything suitable.
The correct way to not "escape" data in blade is with
{!! !!}
, so the code would look like this: