1

I am using CKeditor 4 to format text and store it in a database with Node.js and MySQL. The data type i used to store this is TEXT. Everything is fine until it is stored in the database.
The problem is when i retrieve the text from the database and try to display it using an EJS variable as follows:

<%=result.FormatedText%> 

the browser displays the content in the EJS variable like this:

<p><strong>This is a random text i typed</strong></p> <ol> <li>First item</li> <li>Second item</li> <li>third item</li> </ol> <p>&nbsp;</p>

but I want to display it like this:

This is a random text i typed

  1. First item
  2. Second item
  3. third item

 

How can I solve this?

1 Answer 1

3

Change this:

<%= result.FormatedText %> 

To this:

<%- result.FormatedText %>

It outputs the unescaped value, the browser could now render it.

Check the documentation.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.