Displaying HTML with Blade shows the HTML code
I have a string returned to one of my views, like this:
$text = '<p><strong>Lorem</strong> ipsum dolor <img src="images/test.jpg"></p>'
I'm trying to display it with Blade:
{{$text}}
However, the output is a raw string instead of rendered HTML. How do I display HTML with Blade in Laravel?
PS. PHP echo()
displays the HTML correctly.
Solution 1:
You need to use
{!! $text !!}
The string will auto escape when using {{ $text }}
.
Solution 2:
For laravel 5
{!!html_entity_decode($text)!!}
Figured out through this link, see RachidLaasri answer