Thought i'd try getting twitter's hogan.js up and running with express... not as straight forward as i expected. Drawing upon this article on using mustache.js with express.js i created a simple adapter to help bridge functionality.
I would only use this while connect 3.x is in dev. After that i'd use TJ's consolidate.js cause i'm no TJ.
If you're looking for a full, working example, be sure to checkout a Nodestrap-- a repo i use as a project "prototype." It comes out of the box with better than average architecture, hogan-express templating, bootstrap 1.x. Its a good jumping off point.
Here's the adapter:
Here's an example of it in use:
In the views directory i have a index.hogan.js file-- that's the template.
It's worked for simple uses so far. I'll update if needs be.
you could do this much simpler even for 2x, but with 3x coming out soon I wont go into details
ReplyDelete@TJ updated it per your suggestion
ReplyDeleteIs there a specific syntax needed in the layout file to get layout:true to work?
ReplyDeleteDoes the adapter need to be used somewhere, I'm not sure if this works as-is?
ReplyDeleteWhat version of express is this for ?
It was express 2.x. Given that this code is > 6 months old, perhaps it is dead at this point!
ReplyDeleteYou may want to check out consolidate.js https://github.com/visionmedia/consolidate.js
I'd check out mmm.
ReplyDeletehttps://github.com/techhead/mmm
It has support for layout, partials, and caching. It was made specifically for Express 3.