How to escape HTML in node.js EJS view?

You are escaping the value correctly by using:

<%= bloglist[i].Text %>

If you want to allow HTML to be rendered, then you want an “unescaped” value. To do that use the following:

<%- bloglist[i].Text %>

All I did was replace the equal (=) with a dash (-).

Reference: https://github.com/visionmedia/ejs/tree/0.8.3#features

Leave a Comment

tech