mde / ejs

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

How can I generate an ejs file from an ejs template. #672

Closed AntiMoron closed 2 years ago

AntiMoron commented 2 years ago
<%- console.log('I just want it to stay still') %>

Any implement like ?

<!CDATA[[ <%- console.log('I just want it to stay still') %> ]]>
mde commented 2 years ago

You can use a different delimiter in your template:

ejs.render('<% <@= someVariable @> %>', {delimiter: '@'}, {someData: 'hello'});
AntiMoron commented 2 years ago

@mde Thanks I figured it out with '<%%' to render a '<%' literal.

<%%- someVar %>

renders

<%- someVar %>
mde commented 2 years ago

NIce!

AntiMoron commented 2 years ago

I can see that ejs designed this pattern at BNF stage for this senario. Good job. I took a while to recognize that, maybe the docs should add this.