schutte
schutte

Reputation: 2166

How to display contenteditable contents properly? (laravel) (vue)

I have done saved the contents inside the #descrition below.

<div id="description" contenteditable="true"></div>

My problem is when I try to display it does not display like an html format, it displays same like the saved data with <h1></h1> & <br>. It displays plain text only.

<div id="description" contenteditable="true">{{ $description }}</div>


The content I saved in my database & display:

<h1>Descriptoin</h1> Doner, where I built and maintained banner adverts and microsites. <br> And...

Someone know how to display this properly?


Answer: thanks to @Akram Wahid

In laravel - {!! $description !!}
In vue - <div v-html="description"> </div>

Upvotes: 0

Views: 817

Answers (2)

MEDZ
MEDZ

Reputation: 2295

By default Laravel escape special characters to prevent XSS attack. Try using this format:

<div id="description" contenteditable="true">{!! $description !!}</div>

Upvotes: 1

Mohamed Akram
Mohamed Akram

Reputation: 2117

You have to do like this , because Blade {{ }} statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attacks.If you do not want your data to be escaped, you may use the following syntax:

<div id="description" contenteditable="true">{!! $description !!}</div>

Upvotes: 1

Related Questions