by marstall · 16y ago · 0 comments
Software developers may not have to design their own HTML, but they sure as hell have to write it.
HTML is a huge pain in the ass to write:
* It requires balancing tags
* It's verbose
* It is crudded up with syntax (</-="") and keywords
* It consistently runs right off the 80 column right margin
* It's an enormous pain to extend
* It's slow to read; for instance, try picking the plural version of a constantly-used class name out of tag soup
Haml isn't a shortcut to writing HTML. On the contrary, to use it well, you have to know HTML well. What Haml does is to solve the problems that make HTML a pain to use to express user interface in.
Only for tags that need an ending delimiter, unless you use XHTML. Check out the Google markup sometime. All the <li>, <td>, <tr>, and <img> tags are intentionally unbalanced - because they don't have to be, and balancing them just makes your website take longer to download.
http://dev.w3.org/html5/spec/Overview.html#syntax-tag-omissi...
"It consistently runs right off the 80 column right margin"
I've never had that problem. I also have no qualms about breaking lines between tag attributes.
"It's an enormous pain to extend"
HTML5 "data-" attributes make this a bit easier. Still room for improvement here, though.
A lot of the pain points in HTML are self-inflicted by developers who read some "best practices" on the web and then never question what they get out of those best practices.
What it took for me was writing a UI in Haml with very minimal, semantic markup and all the controls keyed in jQ off classes and IDs.
When you structure your HTML, CSS, and Javascript correctly, Haml is absolutely gorgeous. You're no longer writing in HTML: you're writing in a DSL designed to express user interface. For instance, a "save" button encoded in a DIV in Haml:
.button#save
That's it. Whereas
HAML
is
notInline your HTML: That’s right. Just put some HTML into your Haml document. Don’t be afraid, it’ll be just fine.