Closed MarcDiethelm closed 11 years ago
Which methods are you trying to pass app.locals
and res.locals
into?
I could modify the arguments check in the public methods to be:
if (typeof options === 'function' && options.name !== 'locals') {
callback = options;
options = {};
}
This should work since app.local
and res.locals
are functions with the name "locals"
. What do you think?
That sound like a plan! You could additionally check if options.arity == 1
but that's likely overkill.
For the record I am using the render method, here: https://github.com/MarcDiethelm/xtc/blob/develop/controllers/_default.js#L79
@MarcDiethelm let me know if #28 looks good to you, and if you could try it out locally that would be excellent. If it looks good, I'll publish this to npm.
I tested it, and it's looking good!
@MarcDiethelm the changes in #28 have been published to npm as v0.5.0
.
It's not possible to pass
app.locals
orres.locals
as template context/rendering options into the public API methods. The methods that accept options perform a check if the argument is a function, and if it is it's treated as a callback.app.locals
andres.locals
are function too however. Unfortunately Express doesn't offer a way of getting all the locals' properties at once.In order to use Express locals the exphbs API one is forced to copy the properties over to a fresh object.