A
A
anna_umi2018-01-21 09:40:56
MongoDB
anna_umi, 2018-01-21 09:40:56

How to process JSON from the server so that tags in the JSON file fire when displayed on the site?

Hello everyone, tell me how to process JSON from the server so that tags in the JSON file work when displayed on the site. I accept a string, there is text and tags, everything is inserted in one heap.
Just like in this form I write here - this is a textarea, and when I click Publish, I see the text with processed tags and line breaks.
When developing, I use nodejs, express, pug, mongodb, mongoose, to process formidable forms.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
monochromer, 2018-01-21
@monochromer

-
  var data = {
    html: '<ul><li>1</li></ul>'
  };

//- вставится с экранированием
div #{data.html}

//- вставится без экранирования
div !{data.html}

D
Dimonchik, 2018-01-21
@dimonchik2013

look at the template engine so that html is left as it is
in Dzhang, for example
{{ variable |safe}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question