Web
[ Aslak Hellesoy ] 19:54, Saturday, 26 February 2005

Rich, responsive webapps using the Ajax approach are chic. I've started to think about what it would be like to develop the view part of a webapp using the Ajax concepts.

In an Ajax web app the server sends back XML, and the XML is transformed to HTML in the browser. There are several ways to do this transformation:

One approach is to use XSLTProcessor as described here.

However, XSLT is problematic for a couple of reasons. First, not all browsers support it, and more importantly, most web ui designers don't speak XSL.

A second approach is to use XPath in JavaScript to pull out bits of pieces of the XML and modify small pieces of the DOM to fill them in.

A third (and new?) approach could be to use the familiar template approach (as in JSP, ASP, ERB, PHP templates) and generate bigger chunks of DHTML. This would make it much easier to develop nice looking views, since they can now be designed in a regular web authoring tool such as DreamWeaver or NVU.

But wait - the template engine now has to sit inside the browser! And this is where I discovered JavaScript Templates.

JST templates could theoretically be rendered (and tested) in a build system, using Rhino. Being able to test view rendering is something I consider very important, especially when systems start to get complex (which they do with Ajax).

I'm eager to try this out.