Rendering HTML Tags Laravel 5 Blade Templating

3.6k Views Asked by At

I'm working on a Laravel App and I am displaying a content from the database, the datatype is text and this is the content

<span style="font-weight: bold; font-style: italic;">What is your dog's name?</span>

As you can see it has HTML tags but when I rendered it in my view, instead of formatting the text What is your dog's name? It is displaying the entire content

<span style="font-weight: bold; font-style: italic;">What is your dog's name?</span>

It's not reading the HTML tag. Is there a convertion that I need to do in the formatting? When I view source it,

&lt;span style="font-weight: bold; font-style: italic;"&gt;What is your dog's name?&lt;/span&gt;

Here's my code:

View

<table class="table table-striped table-bordered">                                
    <tbody>
       @foreach($questions as $key => $value)
           <tr>
               <td class="">{{ $value->Question }}</td>
           </tr>
       @endforeach
   </tbody>

My controller:

public function create()
{
    $questions = Question::where('IsEnabled', '=', 'Yes')->get();

    return view('crm.create')->with(array('questions' => $questions));
}
1

There are 1 best solutions below

1
On BEST ANSWER

You need to tell blade not to escape HTML by using this {!! !!}

NB: This is applicable if you are using Laravel 5

@foreach($questions as $key => $value)
  <tr>
     <td class="">{!! $value->Question !!}</td>
  </tr>
@endforeach