express.js消息中的新行 [英] New line in express.js message

查看:71
本文介绍了express.js消息中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在消息通知中添加新行?

Is it possible to make a new line in the message notification?

"\ n"或"\ r \ n"消失了,但是没有设置新行. 我也试过了 var endOfLine = require('os').EOL;而不是\ n.不会很难过.

"\n" or "\r\n" just disappear but there's no new line set. I also tried var endOfLine = require('os').EOL; instead of \n. Doesn't work sadly.

res.render('settings.ejs', {
        user: req.user,
        isAuthenticated: true,
        message: 'Changed User(s):' + changearray + '\n(Notice: You can\'t affect Users with higher Settingrights.)'
        });

可能是一个愚蠢/简单的问题,但我无法正常工作...在此先感谢.

Probabbly a stupid/easy question but I don't get it working... Thanks in advance.

推荐答案

您可以使用html标记.之所以不能显示它们,是因为我想您必须使用escaped文本.如果要在html字符串中呈现标记,则需要使用unescaped语法:

You can use html tags. The reason why they are not getting displayed is because I suppose you must be using escaped text. You need to use the unescaped syntax if you want to render the tags in your html string:

res.render('settings.ejs', {
        user: req.user,
        isAuthenticated: true,
        message: 'Changed User(s):' + changearray + '<br />(Notice: You can\'t affect Users with higher Settingrights.)'
        });

以下是在视图中显示未转义文本的方法:

Here's how to display unescaped text in your view:

<%- message %>

这篇关于express.js消息中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆