用HTML连接flash消息?

时间:2014-10-12 21:01:30

标签: node.js express ejs connect-flash

我想在connect-flash消息的文本中包含一个链接:

JS

req.flash("registerMessage", "Sorry, the User ID you chose is already in use. Please choose another. If you have already registered and need assistance logging in, <a href=\"http://www.example.com/support/\">contact support</a>");

EJS

<% if (message.length > 0) { %>
  <div class="alert alert-danger"><%= message %></div>
<% } %>

结果

<div class="alert alert-danger">Sorry, the User ID you chose is already in use. Please choose another. If you have already registered and need assistance logging in, &lt;a href=&quot;http://www.example.com/support/&quot;&gt;contact support&lt;/a&gt;.</div>

有没有办法阻止Flash转义HTML字符,以便我可以在我的消息中显示链接?

1 个答案:

答案 0 :(得分:6)

您可以使用:

<%- message %> 

输出未转义的HTML