Search code examples
javascripthtmlexpressckeditorbackend

How to make a html page from CKeditor


I am creating a News Blog Website. For composing new blog in the website, I am using Ckeditor as Rich Text Editor. I am using ejs as my view engine, I am using node.js and also express.js

<form action="/compose" method="post">
        <div class="form-group">
            <label>Post</label>
            <textarea name="postBody" id="editor">Start Writing Here.</textarea>
        </div>
        <button type="submit" class="btn btn-primary">Publish</button>
    </form>

    <script>
        ClassicEditor
            .create(document.querySelector('#editor'))
            .then(editor => {
                console.log(editor);
            })
            .catch(error => {
                console.error(error);
            });
    </script>

Now I am using this data and creating a post page

<%= content %>

but when I am opening my post website, I am getting my post content in raw HTML format as shown below

<p><strong>Lorem ipsum</strong> dolor sit amet, consectetur adipisicing elit.<i> Quae maxime</i> dolore necessitatibus iste aliquid dolorum in nostrum repellat rerum atque?</p>

how can I get it in plain text with all the tags applied to it. For eg:- I want like this

Lorem ipsum dolor sit amet, consectetur adipisicing elit.Quae maxime dolore necessitatibus iste aliquid dolorum in nostrum repellat rerum atque? Please help me, sorry for my english or my silly question.


Solution

  • Use this:

    <%- content %>
    

    instead of this:

    <%= content %>