Article image


Javascript -

Oct 11 2019

Dino Numic

Often times we have a rich text editor on our web application that let's the user insert formatted HTML code and store it in the database as such. This can be seen on blogs, such as this one, web shops for products descriptions, and etc.

We can quickly run into issues if we were to just print out the raw HTML code as our Vue application would try to execute it. This is especially an issue if you want to display raw Vue code like bellow.

This would be stored as a content of our article in the database.

        <table class="table table-hover">
                    <th scope="col">#</th>
                    <th scope="col">Name</th>
                    <th scope="col">Email</th>
                    <th scope="col">Updated At</th>
                    <th scope="col">Created At</th>
                <tr v-for="(user, index) in users" :key="">
                    <td>{{ index + 1 }}</td>
                    <td>{{ }}</td>
                    <td>{{ }}</td>
                    <td>{{ user.updated_at }}</td>
                    <td>{{ user.created_at }}</td>
    export default {
        data() {
            return {
                users: []
        created() {
                .then(response => {
                    this.users =;
                .catch(error => {
                    console.log("Error", error)

This is how we would call it.

<div id="body-wrap">
    {!! $article->content !!}

Vue would raise multiple errors over this, from undefined properties and methods, to component registration. In order to solve this issue, we can use v-pre directive. This will tell Vue to skip compilation on this element and elements inside it and just print out the raw content.

<div id="body-wrap" v-pre>
    {!! $article->content !!}

Awesome, isn't it.