Monday, October 20, 2008

hquery: Separate data from HTML ... without templates!

Out of a bunch of cool presentation at least week's San Francisco Ruby meetup, my favorite was Choon Keat's demo of a working implementation of his hquey project -- a lib that lets you use Ruby, CSS, and jQuery patterns to bind data to views ... in the DOM, on the server side.

He had previously blogged about the motivation -- the core idea is that 10-15 years into the web application era, we are largely using template languages for integrating data into HTML. We've come a long way toward avoiding procedural code in our templates, enforcing MVC, etc. But aside from collectively agreeing to avoid a set of 'worst practices,' we're still inserting data into HTML in a manner reminiscent of 1998.

For well designed pages, with CSS classes and/or IDs, it should be possible to specify the data binding using CSS on the server, without any special binding tokens or markup. hquery does just that. So a designer can create full mockups with dummy data, and hquery can swap in the live data

The current demos and syntax might be touch verbose, but this is just an intial proof-of-concept and Ruby lends itself to easy re-arrangement an API if you need to.

This sort of radical division of dynamic data from HTML, while still using standards and not introducing yet-another-meta-templating-scheme reminds me a little of the old idea of using XML+XSLT to create pages. We all know how popular that ended up.

The hquery approach seems about fifty times more accessible to the present community of developers ... so the question is: how do we make this more popular and build community interest?

3 comments:

choonkeat said...

i thought the idea tanked since there was no questions at the end of the presentation. :-)

this is not "brand new", but with the choice of css/xpath and the jquery pattern, i hope the ingredients are right this time.

as for building interest, i'm thinking of launching something like csszengarden. what do you think?

Adam said...

@choonkeat: something like csszengarden would be very cool -- and/or maybe a contest to get folks to submit stuff

Runescape Gold said...

I recently stumbled on the clause and get already been interpretation on. I wish to expressage my personal esteem within your authorship science plus ability to shuffle audience interpret from the beginning towards conclusion. I'd like to learn more sophisticated threads as well as portion my own views along.

RS Gold
Buy WOW Gold