Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blade, Use html inside variable being passed into partial view is not being rendered

I'm using a partial view to display page header, that view accepts two variables one is Icon the other is a title. pageHeader.blade.php:

<div class="page-header"> <div class="row">     <!-- Page header, center on small screens -->     <h1 class="col-xs-12 col-sm-4 text-center text-left-sm"><i class="fa {{$icon}} page-header-icon"></i>&nbsp;&nbsp;{{$title}}</h1> </div> 

and I'm using it like so:

@include('zdashboard._partials.pageHeader',['icon'=>'fa-pencil','title'=>'<strong>Editing</strong>'.$center->translations()->whereLang('en')->first()->name]) 

Sometimes I like to make one word strong or italic like the example above but, blade engine won't render the HTML tags I'm typing as part of title variable (the output like the photo down).

So is there any idea how to solve this? Am I doing it!

wrong?

The output

like image 514
Mo Kawsara Avatar asked Apr 06 '15 11:04

Mo Kawsara


1 Answers

By default in Laravel 5 {{ $title }} construction wil be escaped.

If you don't want the data to be escaped, you may use the following syntax:

{!! $title !!} 

Read more about Blade control structures: http://laravel.com/docs/5.0/templates#other-blade-control-structures

like image 84
Limon Monte Avatar answered Oct 16 '22 19:10

Limon Monte