ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

Using `render()` Inside a Helper #144

Closed ryanfitzer closed 9 years ago

ryanfitzer commented 9 years ago

Is there any way to get render() to execute synchronously? Since render() returns a promise, my helper function returns before the callback has executed.

I have a helper that enables rendering templates from within templates. As long as there are no custom helpers in these nested templates, using Handlebars directly works fine. Including a custom helper in one of these nested templates means I'd need to register that helper with both express-handlebars and Handlebars. This makes things a bit more complex.

ryanfitzer commented 9 years ago

Figured out my issue. Hadn't really wrapped my head around the "middleware" concept fully. Your advanced example had what I needed. Just needed to reread it over and over again until it sunk in :)