Viewed 377 times

Anyone who writes client-side JavaScript is familiar with the DOM - the tree structure that your browser references in memory, generated from the HTML it got from the server. JavaScript can add, remove and modify nodes on the DOM tree to make changes to the page. I find it very nice to work with (browser bugs aside), and very different from the way my server-side code has to generate the page in the first place.

My question is: what server-side frameworks/languages build a page by treating it as a DOM tree from the beginning - inserting nodes instead of echoing strings? I think it would be very helpful if the client-side and server-side code both saw the page the same way. You could certainly hack something like this together in any web server language, but a framework dedicated to creating a page this way could make some very nice optimizations.

Open source, being widely deployed and having been around a while would all be pluses.

4 answers given for "Tree-Based (vs. HTML-Based) Web Framework?"

Accepted Solution

You're describing Rhino on Rails, which is not out but will be soon. Similarly, Aptana Jaxer, however RnR will include an actual framework (Rails) whereas Jaxer is just the server technology.

Aptana's Jaxer AJAX server might be something for you to check out, as it uses JS server-side, as well.

That being said, I would argue that you're better off not generating your markup with print statements or echos, but rather template and hook in your dynamic content.

Jaxer is server-side javascript + the DOM. You can integrate jaxer with other languages, by post-processing their output.

Also in java, php, ... you can use xpath to manipulate the DOM.

I see where you're coming from but it's all a bit moot isn't it. You can't send anything but rendered content to the browser, and you have to do it all in one go (AJAX aside). There's no value from what you are suggesting (from what I can see) as even if you build it tree-like, you're still only building a page which is sent wholesale to the client.