【问题标题】:Insert html in jade through res.render通过res.render在jade中插入html
【发布时间】:2015-06-24 14:16:29
【问题描述】:

在 Jade 中插入纯 html 有一点问题。 我将 html 格式的文本存储在 db 中。路由器将这些数据发送到玉模板。 目前我收到的输出 html 是:

<p>some text</p>
<p>some text</p>

在翡翠模板中我以这种方式获取数据:

| #{content}
div #{content2}

而路由器是这样发送的:

admin.query("SELECT * FROM `Article` WHERE `ArticleId` = " + req.params.id + ";", function (err, data) {
        res.render('static.jade', {
            'title'      : data[0].ArticleTitle,
            'page_title' : data[0].ArticleTitle,
            'content'    : data[0].ArticleContent,
            'content2'   : data[0].ArticleContent
        });
    });

我希望有办法解决它。在数据库中存储翡翠格式的文本将是一个大问题。任何帮助。

【问题讨论】:

    标签: javascript html node.js express pug


    【解决方案1】:

    使用!{ variable } 包含未转义的内容。

    所以:

    | !{content}
    div !{content2}
    

    查看更多here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-17
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 2015-12-21
      • 1970-01-01
      • 2015-08-22
      • 1970-01-01
      相关资源
      最近更新 更多