Yep I've run into that same frustration with templating too. I expressed it as:
"Templating languages are pretty cool because you get to use a declarative language to make some DOM elements. But they either don't give you the full expressiveness of a decent functional language, or they do and it's a bunch of arbitrary stuff stuck in some ugly tags - which I am still way too lazy to learn, when I already have a decent functional language (JavaScript)."
The earliest templating in this style I'm familiar with is FlyDOM. I made a variant SuperFlyDOM. HAML was around and HAML-JSON was not far off, IBM's JXON, jQuery's DOM creation object shorthand... probably more exist.
It makes a lot of sense compared to the antiquated longhand and inflexibility of XML element declaration. Templating in the browser has been done to death and usually string concatenation is the fastest. However, JS frameworks like Enyo/WebOS and Titanium Mobile use JS element creation, so having a shorthand for those is not significantly slower.
HAML is nice because it removes the computer cruft of braces and brackets, but building JS objects with CoffeeScript is just as quick. IMHO the only reason not to use the actual language is so that less technical UI devs can build the templates.
4 comments
[ 3.5 ms ] story [ 15.8 ms ] thread"Templating languages are pretty cool because you get to use a declarative language to make some DOM elements. But they either don't give you the full expressiveness of a decent functional language, or they do and it's a bunch of arbitrary stuff stuck in some ugly tags - which I am still way too lazy to learn, when I already have a decent functional language (JavaScript)."
My solution is about the same - https://github.com/pidge/h
It makes a lot of sense compared to the antiquated longhand and inflexibility of XML element declaration. Templating in the browser has been done to death and usually string concatenation is the fastest. However, JS frameworks like Enyo/WebOS and Titanium Mobile use JS element creation, so having a shorthand for those is not significantly slower.
HAML is nice because it removes the computer cruft of braces and brackets, but building JS objects with CoffeeScript is just as quick. IMHO the only reason not to use the actual language is so that less technical UI devs can build the templates.