visionmedia/ejs — Issue #39: [documentation] On the client-side, variables must be in the 'locals' option
Author: fzaninotto
Created: 2012-01-12 10:13:18+00:00
State: open

While trying to use EJS on the client side, I reproduced the example from https://github.com/visionmedia/ejs/blob/master/examples/client.html, but it didn't work. The variables I passed to the `render()` function weren't passed to the template:

```js

```

With this template, the console complained that the `names` variable wasn't defined when interpreting the template.

After fiddling with the EJS source code, I found out that variables would only be passed to the template if they were under the `locals`option, so the line:

```js
var html = require('ejs').render(users, { names: names });
```

should be replaced by:

```js
var html = require('ejs').render(users, { locals: { names: names }});
```

...for the example to work.

Or did I miss something?