Thoughts on Haml
jamesbritt.com
jamesbritt.com
HAML - Great for application markup (as opposed to document markup... see ERB below) for a number of reasons. (1) application markup tends to be heavy in javascript where you need a clean DOM. HAML reduces the chance of screwing up the DOM and makes it easier to look at during development. (2) Lots of conditionals in the view and I'm too lazy to factor them out into partials or helpers. Sometimes its just easier to express if/then and loops in HAML than it is in ERB... slightly less markup.
ERB - Document/content markup. If I have big docs with lots of links and paragraphs, but nothing to heavy going on thats dynamic/conditional, ERB is the easiest way to go.
Mix 'n' match! Then you can have the best of both worlds!
Code management (breaking things up into appropriate templates and fragments) trumps things like HAML for ease of use and clean separation every time.
I will concede that it can cause friction with designers though.
Jquery + Haml is a very close impedance match and a real pleasure to use for development.
Take the following Haml that defines a div with an id of "foo" along with a span with class "bar" and content "Hello World":
#foo
%span.bar Hello World
If I wanted to hide those elements, I'd write the following jQuery in a separate file: $('#foo').hide();
$('span.bar').hide();
That's really powerful stuff. The Haml syntax for defining elements looks exactly like the CSS3-style selectors used by jQuery, so much so that I often cut and paste my Haml markup into my javascript files.Turning it into haml has two benefits. I can visualize the structure of repeating elements so I have a better idea what to break into partials and I will never forget a closing tag which causes everything to break in some horrific way.
That said, I'm quite interested in using Sass.
http://stackoverflow.com/questions/93540/your-attitude-to-ha...
I converted an ERB file to HAML. A quick glance shows it to be simpler... even though it's mostly the same code: http://pastie.org/private/n8ipfrkxlremo4jwtxiww
More detailed response is here: http://railsnotes.com/395-response-to-thoughts-on-haml/