I have following code in nodejs (I read temp.ejs file and get content as ejsHtml as string):
var html = EJS.render(ejsHtml, { A: '<div>smth</div>' } );
And in temp.ejs:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<%= A %>
</body>
</html>
Output:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<div> smth </div>
</body>
</html>
Please tell me how to get Html and not that
For outputting escaped html, you do the following:
<%= code %>
To output unescaped html, you would use the following
<%- code %>
I used underscore to help me out. Only <%=
or <%-
did not work.
<%- _.unescape( data.textWithHtml ) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With