News for hackers. Stuff that matters.
Re:Stop sending template engines to the browser. How to make... by nfriedly on Thursday September 13, 2012 @08:16PM (#4519362)
Same here. I had some trouble with partials until I realized that you can just compile everything as a template and then do

    Handlebars.partials = Handlebars.templates
:)
Re:Stop sending template engines to the browser. How to make... by ahoge on Thursday September 13, 2012 @09:33PM (#4519585)
I use:

    Handlebars.registerPartial("Foo", Handlebars.templates.Foo);
Your approach is kinda amazing. Makes me wonder why not all templates are automatically available as partial by default. Are there cases where you wouldn't want that?
Re:Stop sending template engines to the browser. How to make... by nfriedly on Friday September 14, 2012 @12:07AM (#4520024)
I think the reason is Handlebars is supposed to look and act like Mustache and templates aren't named in Mustache, so they don't get named in "regular" Handlebars:

    var getHtml = Handlebars.compile("<div>yad yada...</div>");
And then following the rule of least surprise, if templates aren't partials during normal usage, then they shouldn't be with precompilation.

At least that's my guess. I didn't figure out my trick until digging through the source to figure out what was different. (Not much - just how/where they're stored & referenced.)

Re:Stop sending template engines to the browser. How to make... by ahoge on Friday September 14, 2012 @12:21AM (#4520050)
Ahm... yea, I forgot that I put them into `Handlebars.templates` myself if they aren't there yet (i.e. during development).