I have to say, reading this made my day. I've been feeling such a push towards client-side templates lately, that I felt like it was just me that didn't get it. I really don't understand what's so compelling - unless those exact same actions are actually (YAGNI) used as endpoints of a web service. render :partial => '..' is such an sweet, simple and natural paradigm to web programming.
Hey, I totally agree that if your actions are gonna be consumed by clients other than your own UI, it makes total sense. However, I've seen people [strongly] advocating this approach even when this isn't the case..that's what I don't get.
Though I suspect you're just talking about cases that are best chalked up to: there's no accounting for the logic of the illogical.
[1] If you want to ensure a separation between display code and business logic, it's not a bad way to draw a line; some heavily data-driven problems do tangibly benefit from fetching JSON and formatting on the client; solutions that have multiple views on essentially the same data sets benefit in much the same way that solutions with multiple clients benefit; etc.
I think you nailed it with "unless those exact same actions are actually (YAGNI) used as endpoints of a web service". I find client side javascript apps compelling because they are simply another consumer of your web service along with any other mobile/third-party/customer apps.
In my head it's much easier to imagine manipulating a UI based on objects and their state, rather than partial snippets of HTML. It seems like it would get complicated to track the pieces of html you needed to request in order to redraw only portions of the UI. Wouldn't there still be a lot of javascript involved with that logic?
Normally that basic cycle would go:
1. I need to view some data, if I do not already have it, request it.
2. Generate html from data
3. Take generated html and place in appropriate place on page.
This skips step 2 by requesting the required html rather then the raw data. Step 2 is the part that would require the most code.
I disagree. I work on an app that is entirely client side rendered. We use the JSON data approach. Step 2 is trivial. There are many JS templating engines out there. It takes almost no code. The part that's hard is step 1, figuring out if you have the right data or whether your data is stale. And then, to figure out which part of the UI needs to be redrawn. This is where frameworks like Backbone can come in handy.