mde / ejs

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

Ejs inside script tag! #633

Closed moriseif closed 3 years ago

moriseif commented 3 years ago

I have this code but I see a is not defined! .... <% const a="hi"; %>

mde commented 3 years ago

It doesn't work that way. EJS renders the HTML template in its own context, usually on the server. That <script> tag is just part of the rendered HTML. The browser JS runs in the browser.