ejs icon indicating copy to clipboard operation
ejs copied to clipboard

options.scope no longer has effect in render

Open hpaulj opened this issue 12 years ago • 1 comments

In [email protected]

test='this test in base'
console.log(ejs.render('<%= this.test %>'))
console.log(ejs.render('<%= this.test %>',{scope:{test:'in scope'}}))

produces

this test in base
in scope

in [email protected], both lines produce this test in base

This appears to be the result of https://github.com/visionmedia/ejs/pull/79 which wraps the template code in a function(){...}().

Using option._with:false, gets around this problem

hpaulj avatar Jun 18 '13 06:06 hpaulj

I think this issue would be resolved by changing the template compile to produce

(function(){...}).call(this)

In other words, pass the scope through the new function layer.

hpaulj avatar Jun 21 '13 01:06 hpaulj