--
You received this message because you are subscribed to the Google Groups "mustache.java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mustachejava...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Ok, just want to make sure I follow you: in the cases where the client calls the API, you guys do NOT get JSON back, then render mustache, then update DOM? But instead the client makes an API call and gets back rendered HTML, then just plops that into the DOM - the kind of old, regular way, right?
My approach is that the server fully renders like 80% of the page templates (layout, header, sidebar, footer), with the remaining 20% (just rough numbers here) being "precompiled" (this would be like a template for search results, which can't be rendered because we don't have data because the user hasn't searched yet). So all that goes to the client and then the user searches, AJAX brings back data, mustache.js uses that data to render the precomiled template, in the DOM it goes and we're done.
What benefit does this have? All the speed and simplicity of server-side rendering + get to do client-side rendering when it makes sense + our API calls only bring back data, which can get used and reused across the UI. Bringing back the results as rendered HTML is faster and makes sense in some cases, but getting plain old JSON frees us up to use that data for a bunch of different stuff.
Thoughts?
Here's what makes the most sense to me:A request comes in for our search page, we want to send back a fully-rendered mustache template. Good, we can do that. That's super fast!The search page has a search box with auto-suggest, which makes an XHR call to a third-party for its suggestion data. No problem! That's much better than a page reload.The suggestion data comes back and we want to render the results using a mustache template. Uh oh! The server already rendered that part of the template, i.e. our 'suggestions' partial!We have to A) go old school and write some jQuery DOM manipulation, or B) send another request (XHR or full request) to our server with this suggestion data and get back a rendered 'suggestions' template. Neither of those make sense.
A 'C' option of originally getting a rendered template with compiled partials included in the response would be ideal. That way we can use those compiled partials client-side and avoid any additional requests for rendering suggestion results. So basically after the initial page request, which returns a partially-rendered page, the client can then easily re-render parts of the page with data that comes from all kinds of services (back to your own server, third-parties, etc.). This is the ideal hybrid approach that lets front-end engineers do what makes most sense for a given scenario.
What you described is great for a lot of cases, but if you need the client to get data AND render a template you can't (well, without doing really slow template compilation in the browser).
So, how about a 'hybrid' option in Mustache.java?
Thanks Sam, can you share a code example on replacing isEmpty? Do you just have boolean? Second, is there a setting I can set to error out if a developer uses something on an underlying data object?