ejs icon indicating copy to clipboard operation
ejs copied to clipboard

Cannot render HTML with EJS template

Open blake-edwards opened this issue 7 years ago • 2 comments

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: screen shot 2018-09-15 at 2 36 24 am

If someone could explain to me why this current implementation is not working as expected that would be greatly appreciated!

blake-edwards avatar Sep 17 '18 01:09 blake-edwards

i have the same problem

andreiverse avatar Sep 28 '18 18:09 andreiverse

@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!

blake-edwards avatar Oct 03 '18 05:10 blake-edwards