I have a string returned to one of my views, like this:
$text = \'Lorem ipsum dolor
For laravel 5
{!!html_entity_decode($text)!!}
Figured out through this link, see RachidLaasri answer
You can do that using three ways first use if condition like below
{!! $text !!}
The is Second way
<td class="nowrap">
@if( $order->status == '0' )
<button class="btn btn-danger">Inactive</button>
@else
<button class="btn btn-success">Active</button>
@endif
</td>
The third and proper way for use ternary operator on blade
<td class="nowrap">
{!! $order->status=='0' ?
'<button class="btn btn-danger">Inactive</button> :
'<button class="btn btn-success">Active</button> !!}
</td>
I hope the third way is perfect for used ternary operator on blade.
For who using tinymce and markup within textarea:
{{ htmlspecialchars($text) }}
You need to use
{!! $text !!}
The string will auto escape when using {{ $text }}
.
You can use {!! $text !!} for render HTML code in Laravel
{!! $text !!}
If you use
{{ $text }}
It will not render HTML code and print as a string.
If you want to escape the data use
{{ $html }}
If don't want to escape the data use
{!! $html !!}
But till Laravel-4 you can use
{{ HTML::link('/auth/logout', 'Sign Out', array('class' => 'btn btn-default btn-flat')) }}
When comes to Laravel-5
{!! HTML::link('/auth/logout', 'Sign Out', array('class' => 'btn btn-default btn-flat')) !!}
You can also do this with the PHP function
{{ html_entity_decode($data) }}
go through the PHP document for the parameters of this function
html_entity_decode - php.net