Once upon a time, there was a…
Nah, that’s silly. Here’s the thing: Smart, smart people keep saying how great Haml is. I’ve looked at it five or eight times, and each time, I quickly stopped looking at it. It just struck me as fussy and precious, and I already like HTML or Markdown just fine. So, no trouble: I just won’t use it. No muss, no fuss.
Today though I submitted some content to a website. The site is about a piece of software I care a lot about, and the developer invited me to write something up (because I kept making trouble about it). I wanted to help out, so I forked the site’s Github repo, cd into the relevant directory and…oh, crap, the files end in .haml. I popped back into irc, joked a little about Haml and fired up my editor.
At first, things were fine. Haml is in fact fussy and precious, but nothing I can’t survive. (By the way, when I say ‘fussy and precious’, I have in mind the love of whitespace and hatred of braces, brackets and punctuation that Haml displays. I find that precious and fussy, but obviously a lot of people disagree. Maybe I have poor taste.) Then I wanted to do the following: surround three words in a sentence in an <a> element to make those words (only) a link. The other words in that sentence — the words before and after those three — should be left alone. So I look at some Haml files and, hmm, that’s odd.
To make only selected words a link, you need to add a newline at the end of the link. So you do something like this:
%p
Now if you really like
%a{:href => "http://haml-lang.com"} Haml
you should visit their website.
The content below that should start at the same level of indentation as the line above it.
Initially, that seems dumb but sort of ok. It’s dumb that there’s no way except a newline to tell the Haml parser that you are done linkifying text, but, well, maybe that’s ok.
I kept writing. Now I wanted to emphasize one or two words in a sentence. Then I wanted to wrap one or two words in a sentence in <code> tags. Can you guess how to do those? Yup:
%h2 Heading content
%p
This is just some
%em emphatic
text. Maybe I'll talk about
%code $BASH_VERSION
here.
Seriously. Please let that sink in. Every freaking time you want to use <em>, <code>, <strong> or the like, you need to enter a newline. Your content becomes these little three to five line squibs. Don’t believe me? Try it yourself at Html2Haml. Just enter this:
<h2>Heading content</h2>
<p>This is just some <em>emphatic</em> text. Maybe I'll talk about <code>$BASH_VERSION</code> here.</p>
I finished my bit of content, pushed up to Github, sent a pull request. Wow. Just wow.
Shortly afterward, I tweeted this:
Who has two hands that love to type and hates #haml? (Now imagine me waving my #haml-hating hands in the air like I just don’t care.)
And a bit after that, I added this one:
If you don’t hate any software (libraries, code) - really hate, deep deep down - then I don’t think I trust your judgment.
I stand by both.
This post was found among the papers of a sad, deluded old….
Nah, that’s stupid. Here’s the thing: I should admit that I’ve used Haml for a total of about 15 minutes. It may be absolutely amazing, as good as everyone says. Also, I may be very wrong about wrapping select words in <code> or <em> tags. I popped into #haml on irc, but didn’t get any response. If I’m dead wrong, please let me know by email (telemachus /at/ arpinum /dot/ org) or on Twitter (@telemachus). I’ll be happy to update this by eating some crow.
Posting this was helpful for two reasons. First, I learned something. Second, I let off some steam. So what did I learn? It turns out that Haml can handle what I wanted pretty easily.
Second, apparently Haml really isn’t made for chunks of content. This is well-known to people other than me, and a popular solution is to use a filter, like :markdown or :textile. So it might look something like this:
%p
:markdown
This is some *emphatic* text. Now here's `$BASH_VERSION`
Thanks to all the commenters on Hacker News and the people who responded on Twitter. Many of them told me pretty clearly I was an idiot, but I learned something. I can live with that.
While I’m here again, Chris Eppstein wrote a post called Haml Sucks for Content. You should probably read it, since it’s more accurate and fairer to Haml than mine was.