问题
I am creating a blog website with an admin panel in which a user can write the body of the blog's content in the text editor tinyMCE. Currently my schema for blog body is set to string but everytime I write a blog you can see the html marks around the blog and the markup is not recognized as html. Is this an issue with the schema being set to string?
回答1:
I use it in my projects in a similar way. I save tinyMCE content to mongo as a string and thus is saved with the html tags. If you want display these contents out of tinyMCE editor you have to make the template language output the unescaped value into the template. Lets say that your data are stored as description
. If you use ejs you can display it without html tags using this <%- description %>
.
来源:https://stackoverflow.com/questions/54188389/how-to-create-a-mongoose-schema-that-saves-input-as-html-in-mongodb