我试图将需要包含新行/刹车线的值传递到pug文件中。
到目前为止我已经尝试过
var value1 = "value 1";
var value2 = "value 2";
var infromation = "\n" + value1 + "\n" + value2;
res.render('pugfile', { information: information });
但是当它在哈巴狗中呈现时
p Your messages are: #{information}
html呈现为
<p>
value 1
value 2
</p>
但新行没有显示在显示的网页上,这就是问题所在。请帮忙?
而不是将\n
用于换行,使用<br>
进行休息。而且你还需要逃避字符串。供参考check this。
试试这个。
let value1 = "value 1";
let value2 = "value 2";
// let information = "\n" + value1 + "\n" + value2;
let information = "<br>" + value1 + "<br>" + value2;
res.render("index", { information: information });
而在帕格模板
p Your messages are: !{information}