http://github.com/sxross/js_xmlmarkup/tree/master
There are some examples in the README, but for a taste, say you are
populating a table from your database:
xml = new XmlMarkup();
xml.tag('table', function() {
xml.tag('thead', function() {
xml.tag('tr', function() {
xml.tag('th', 'common name');
xml.tag('th', 'species');
xml.tag('th', 'genus');
xml.tag('th', 'family');
})
});
// This part is the interesting part from
// the perspective of using an ORM -- you
// just keep writing Javascript. No slipping
// into HTML and popping back out. Control
// structures and markup instructions in the
// same language, oh my!
xml.tag('tbody', function() {
for(animal in Animal.all()) {
xml.tag('tr', function() {
xml.tag('td', animal.common_name);
xml.tag('td', animal.species);
xml.tag('td', animal.genus);
xml.tag('td', animal.family);
})
}
});
});
jQuery('#animal-family').html(xml.target());
This is only in use in my code at present, so it's very early stuff. I
have one optimization planned that should help with large recordsets.
It's simple and brutally obvious -- I just haven't gotten around to it
yet. I will be changing the string concatenation into array assembly
to reduce the string allocation and discarding.
Steve