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

best practice to share handlebars helpers to the client #50

Closed 0xgeert closed 10 years ago

0xgeert commented 10 years ago

Looking for best practice / suggestions to expose handlebars helpers to the client.

crazy idea: I'm thinking of having grunt write a js-file to public/js containing all needed helpers client-side. This based on introspecting all handlebars-templates in the shared folder (as per the advanced example) and looking for used helpers.

ericf commented 10 years ago

One option would be to add the UMD wrapper around the helpers.js file so it can be served to the browser and hang off of window, or register with the AMD and Node.js module systems. Do you have that many helpers that you don't want to simply send all the helpers to the client?

TYRONEMICHAEL commented 10 years ago

Check out browserfy, where you can share modules between the client and server.

ericf commented 10 years ago

Closing this to focus on v1.0 issues. Feel free to continue the conversation though.