ejs
ejs copied to clipboard
Cannot render HTML with EJS template
Here is the code I am using to render blog posts that will contain HTML. The HTML, as seen in the picture below, is rendered as text even though I used <%- in order to allow HTML. Is there a bug or is there something I am missing here?
<% for(var i=0; i < result.length; i++) { %>
<div class="card">
<h2><%= result[i].title %></h2>
<h5>Posted: <%= result[i].posted %></h5>
<p><%- result[i].body %></p>
</div>
<% } %>
Output example:

If someone could explain to me why this current implementation is not working as expected that would be greatly appreciated!
i have the same problem
@ndr3w221 Somehow the EJS template now displays HTML. I changed nothing in my code. Try using
in your text you are trying to display and get back to me. I am very confused but happy it is working!