donpark/hbs — pull request #66 by jas (2014-06-05 20:46:39+00:00)
Title: Allow helpers to be created per-request

There are some helpers that I need to register on each request in order to access `req` in them. This pull request allows helpers to be registered by passing a `helpers` object in the render options when the Handlebars template is compiled.

#### Example

```javascript
res.render('page', {
helpers: {
foo: function() { return 'bar' }
}
});
```

You can register a helper in middleware for every request to access `req`:

```javascript
app.use(function(req, res, next) {
res.locals.helpers = {
translate: function(key) {
return req.i18n.t(key);
}
};
});
```