mde / ejs

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

locals is not defined after upgrading the ejs to the latest version #698

Closed odaper closed 1 year ago

odaper commented 1 year ago

Hello

I'm using the locals to access the variables passed to my ejs templates using yeoman v4 and ejs v2.7, for example: <% const myParam = locals.myParam; %> When I upgraded the ejs to the v3.1.7, the locals variables is no more defined.

How can we solve this issue? the locals is no more defined in ejs v3?

Thanks for your help

mde commented 1 year ago

EJS by default uses with to set locally scoped versions of the variables you pass. If you want to use the locals object, you need to set the _with option to false. See the docs here: https://ejs.co/

odaper commented 1 year ago

Many thanks @mde