Open hurrymaplelad opened 11 years ago
I like this! We should look into consolidate.js more and figure out the API. I'll think about it a bit this week, but glad to see a PR!
Great! I'll cobble something together.
I've used consolidate.js quite a bit; it can be a little hamfisted in dealing with differences between rendering APIs, but it's also really easy to hack on should we find something wanting. :+1:
Got enough together to start a discussion by forking the app-template: https://github.com/hurrymaplelad/rendr-app-template/tree/teacup
Tried to keep glue code contained in /rendr-teacup. There's some configuration for stitch and watch in the Gruntfile.
The custom templateFinder is wired up in my app's BaseView and the custom viewEngine is setup in server/server.js.
Open questions include:
/rendr-teacup
? If so, can we distill choosing an adapter to 1 line by default, maybe app/app.js
, maybe in a config file? Probably tricky to simplify Gruntfile integration without overly strict conventions, but per adapter example configuration might be enough.viewEngine
is mostly copied from the rendr default. Should we pull out a baseViewEngine or somesuch? It'd need to export all its methods instead of hiding them within the module scope as it does now. viewEngine.getLayoutTemplate
seems to duplicate some of templateFinder
's work. We could have viewEngine
hold the name of the layout template ('layout' by default) and delegate to templateFinder
for the actual loading, but that risks bloating client code by either sending __layout to the client or asking templateFinder
to handle shared and server-only templates differently.Still exploring Consolidate.js integration.
Getting closer. Migrated the whole app-template to teacup + coffeescript. Centralizing configuration in app.coffee. Looks like there's a pretty clear path to choosing a template adapter from a config/
file.
Next step is a pull request on Rendr with rendr-handlebars
extracted into a separate node module and configured by default.
Sweet! Thanks Adam. I haven't had a chance to go through this yet but I'll try today or tomorrow.
On Wed, Apr 17, 2013 at 1:06 AM, Adam Hull notifications@github.com wrote:
Getting closer. Migrated the whole app-template to teacup + coffeescripthttps://github.com/hurrymaplelad/rendr-app-template/tree/teacup. Centralizing configuration in app.coffeehttps://github.com/hurrymaplelad/rendr-app-template/blob/teacup/app/app.coffee. Looks like there's a pretty clear path to choosing a template adapter from a config/ file.
Next step is a pull request on Rendr with rendr-handlebars extracted into a separate node module and configured by default.
— Reply to this email directly or view it on GitHubhttps://github.com/airbnb/rendr/issues/9#issuecomment-16492282 .
Spike Brehm Software Engineer www.airbnb.com
San Francisco, CA, USA C: (602) 828-2358 See how Airbnb works https://www.airbnb.com/info/how_it_works
Dang, sorry for the long delay on this. I WILL merge something in in the next few days.
Thanks for checkin in, hope its not stressin ya. No real rush on my end. Just don't want to lose momentum.
On May 28, 2013, at 5:23 PM, Spike Brehm notifications@github.com wrote:
Dang, sorry for the long delay on this. I WILL merge something in in the next few days.
— Reply to this email directly or view it on GitHub.
Cool! I'd love to sync back up to see how you guys are using it. I'm in the process of prepping a 0.5.0 release which has a number of breaking changes.
Nabbed from the TODOs.
I'd love to integrate Teacup for more CoffeeScript bliss. It's hardly the most popular solution but integration should be simple, so I think it's a sensible first step. Including templates directly in the View modules could be fun, since they're already one to one.
Alternatively, we could go big and add pluggable support for the Consolidate.js signature.
Looks like I'll need to hook into
view.getTemplate()
and maybe write atemplateFinder
and some helpers.Biggest questions are where and how to choose a template engine. App smells about right. We could borrow Express's
app.engine(extension, function (path, options, callback))
signature. Requiring templates to map to paths seems limiting to me but I might be the minority.