visionmedia/ejs — pull request #79 by anatoliychakkaev (2012-10-27 17:27:15+00:00)
Title: Allow named functions with no breaking 'with' scope

Hi TJ,

This fix for named functions in views. Sometimes very useful to have named function in view (temporary helper). Unfortunately, in current implementation named function breaks `with (locals) {` scope. As result member of locals not available in body of named function:

```javascript
with ({a: 1}) {
fn(); // error a is not defined

function fn() {
console.log(a);
}
}
```

To fix it I suggest to wrap with body with anonymous function, which will save locals scope for named functions defined in view:

```javascript
with ({a: 1}) { (function () {
fn(); // 1

function fn() {
console.log(a);
}
})(); }
```

Thanks,
Anatoliy