2

So i have the following value:

$content = "<ol><li>AbC</li></ol><p>sd</p>"

Now I wish to display this on my page.blade.php

But I am not quite sure how to do it. I have attempted with:

{{$content}}

But as expected it just prints the HTML and does not actually inject it.

So my question is how do I inject the HTML?

1

3 Answers 3

3

Try the following-

{!!$content!!}

{{ }} will result in auto escape of string.

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure you are passing variable to your view. Then you can access this by 2 ways:

{{!! $content !!}}

or

<?php echo $content; ?>

1 Comment

{{!! is an error, it's {!! or {{. Also, you shouldn't have to use <?php ... ?> tags in .blade; goes against the point of using it.
0

Try following code:

 {! html_entities_decode($content) !}

2 Comments

Hey, welcome to the site and thanks for your answer. Maybe you might want to edit your post to expand upon what this is doing and why this solves the problem? It'll help the poster and other people who come across this question understand what is happening better.
okay thanks for your comment i'll keep in my mind it for next answers and posts. So Thank you :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.