I use Node.js with Express and EJS and I want to pass html tags in a string to the browser like this:
listRequests.forEach(function(key) {
messages.push("You have a message from <b>" + key.username + "</b>");
});
Later in my code:
res.render('/wallets', {
messages : messages,
...
});
And in my html template, I have something like
<h2>Messages</h2>
<% messages.forEach(function(message) { %>
<p><%= message %></p>
<% }); %>
The problem: the browser displays the text with the tags like <b>John</b> instead of John
{ text: " You have a message from", username: "John"}. Then just use the two attributes in the template. <p><%= message.text %> <b><%= message.username %> </b></p>