从MongoDB中检索HTML标记

时间:2014-03-09 14:46:55

标签: javascript html json mongodb pug

我将此对象转换为 MongoDB enter image description here

我正在尝试检索<script>标记之类的正文内容,但它的绘图类似于 String

这是 Jade 文件:

doctype html
html(lang="en")
  body
    each post in posts
      div= post.title
      div= post.body

最后,如果我编辑为HTML ChromeDevTools 中的代码,则返回

<div>&lt;script src='https://gist.github.com/benatespina/9446679.js'&gt;&lt;/script&gt;</div>

2 个答案:

答案 0 :(得分:0)

您需要告诉jade不要使用!=

来逃避您的HTML代码
doctype html
html(lang="en")
  body
    each post in posts
      div!= post.title
      div!= post.body

Jade documentation

中的来源

答案 1 :(得分:0)

试试这个:

doctype html
html(lang="en")
  body
    each post in posts
      div= post.title
      div= !{post.body}