The following should be true up to ejs 0.8.3:
<% log = “hi” %>
<%= %> or [%= %] is used to execute code, and then print the tostring of the result to the screen. Thus, something like
<%= log %>
will print out ‘hi’ to the screen. Note that HTML is escaped when using this tag. Thus, <%= <img src=”blahblah”> %> will print literally ‘<img src=”blahblah”>.
<%- %> is used to allow ‘unescaped buffering’, which essentially means that HTML is NOT escaped, and thus you can do something like <img src=”blah”> and have an image actually render to the page.
<% -%> tag slurps a newline following the expression. Thus, something like
var x = ‘inbetween’;
str = ‘me <%= x %> \nhere’;
should return the result ‘me inbetween here’ (newline after is slurped).
The last tag was added to ejs in this github chain for those interested: