1
I am developing a news portal in Node.js where I save the posts in a Mysql database. As a template engine, I use the EJS.
Use the Tinymce plugin to format the text of posts (use bold, Italic and etc). Tinymce is a robust Web page visual editor written completely in Javascript.
This plugin saves in the database the text already formatted in HTML. For example:
<strong>negrito</strong> e <p>texto em paragrafo</p>
The problem is time to present this content. I query the database and return with the tags, not the formatted text. I’m calling the tinymce the right way:
<script src="tinymce/tinymce.min.js"></script>
<script>tinymce.init({ selector:'textarea' });</script>
And it is saving right in the bank. But when I perform the query to view, it shows so:
The view code is this:
<div class="col-md-12">
<div class="noticia_wrapper">
<span class="noticia_autor"><%= noticia[0].autor %></span>
<span class="noticia_titulo"><%= noticia[0].titulo %></span>
<span class="noticia_data"><%= moment(noticia[0].data_criacao).format('DD/MM/YYYY') %></span>
<br />
<p class="noticia_resumo">
<%= noticia[0].noticia %>
</p>
</div>
</div>
Someone can give a light?
My friend Sergio, thank you very much. I have been racking my brain about this for some time now... I confess I didn’t know about the escape and not escape HTML thing, so when I looked at the documentation, I couldn’t find the solution. Thank you very, very much, man.
– rodzan
@Rodrigozandonadi great to be able to help. If you want you can click and mark the answer as accepted.
– Sergio
Sergio, I tried, but as a new user my vote is not computed... Sorry
– rodzan
@Rodrigozandonadi to accept do not need points. It is a symbol under the voting arrows and the score of the answer.
– Sergio
@RodrigoZandonadi https://pt.meta.stackoverflow.com/q/1078/129
– Sergio