Search code examples
laravelvue.jsvuejs2contenteditablelaravel-6

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>


Solution

  • 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>