Home » Php » php – Output raw HTML from Laravel

php – Output raw HTML from Laravel

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have a form containing a textarea that stores user input in a table.

Currently when I pull this data in my view, {{ $data->textarea }} it outputs <strong> as &lt;strong&gt;. I’d like to either use or build a very basic WYSIWYG editor, but I don’t think it will work if I can’t output the raw HTML.

Is there some sort of attribute I need to define in my view or controller?


Meta: Would it be wiser to create a system like the Stack Exchange or Reddit where **this is bold text**?

How to&Answers:

I’m assumng you’re using the latest version of Laravel 5 because it escapes everything by default. If so then you need to use one brace and two exclamation marks to tell Blade not to escape it. This should do what you need:

{!! $data->textarea !!}