mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.71k stars 846 forks source link

Data with < or > still escaping despite tag configured otherwise #655

Open mikeerickson opened 2 years ago

mikeerickson commented 2 years ago

In short, I have the following

This is an encoded variable <%- myVar %>

When the template is rendered, it is escaping the < and > characters

This is an encoded variable &lt;mike&gt;
ejs.render('<%- myVar %>', {myVar: 'mike'})

I am expect output to be

<mike>

What should I be doing to make sure the < and > are actually rendered

emmyarty commented 1 year ago

Your output wouldn't include the angular brackets in the first place since the only brackets there are part of the EJS tag, so I don't think EJS is what's causing your problems here.

Are you trying to create html tags called Mike on the fly? Because you could probably do something like ejs.render('<%- ``\<${myVar}>`` %>', { myVar: 'mike' }); for that.

Otherwise you'll want them escaped.