How to Display HTML in Laravel Blade ? Quick Answer

December 28, 2022
Laravel
How to Display HTML in Laravel Blade ? Quick Answer

In this short guide, you will learn how to display the HTML in laravel blade.

There are many cases, in which you are sending the HTML from the controller to the blade view. In that case you need to render the HTML into the laravel blade.

Now if you use an ordinary style of display variable which is {{$content}} you will notice that it will not render the HTML but will show HTML text itself.

{{ $content }} gets converted to <?php echo e($content); ?>

//which will not render HTML which contains in the $content variable but will show HTML as text

How to Display HTML in Laravel Blade ?

To display the HTML in laravel blade, you need to use {!! $content !!}. Using that you can render the HTML in blade. Here is example

{!! $content!!} gets converted to <?php echo $content; ?>

//which will render the HTML contains in the $content variable

Conclusion

In the above post, we have discussed how to display HTML in laravel blade. Let me know if you have any questions in comments.

See you in the next one.

Write a Reply or Comment

Your email address will not be published. Required fields are marked *


Icon