使用Node.js将换行符从JS转换为HTML

时间:2014-06-08 13:27:10

标签: javascript html node.js pug

假设我的对象data定义如下:

res.render('index', {
    data: 'Line one\nLine two' });

如何在html中正确呈现其值(通过使用Jade作为模板引擎)将文本分成两行?

注意:使用\<br\>代替\n,它仍然无效。

1 个答案:

答案 0 :(得分:0)

试试这个

res.render('index', {
    data: 'Line one <br/> Line two'
})

并在index.jade

  != data