

I Hate Haml - telemachos
http://ithaca.arpinum.org/2010/11/16/haml-hate.html

======
marknutter
In which the OP can't figure something out so they choose to flame it instead.

The OP provides the following example as a irrefutable damnation of haml:

%h2 Heading content

%p This is just some

    
    
      %em emphatic
    
      text. Maybe I'll talk about
    
      %code $BASH_VERSION
    
      here.
    
    
    

They complain about the inability to nest em and code tags on a single line.

Hey OP, try this:

%h2 Heading content

%p This is just some <em>emphatic</em> text. Maybe I'll talk about
<code>$BASH_VERSION</code> here.

or did you forget that you can mix html in with haml where needed? Pointless,
sloppy, flame-bait. /endrant

I was reluctant to learn HAML myself, but after being "forced" to do so on a
project last spring, I actually cringe when I see standard HTML and CSS now.
Not only has haml shrunk the size of my code by almost half, it has made it
easier to scan, maintain, and my css matches up much more closely to my
markup. Simply put, HAML/SASS is one of the biggest productivity/sanity boosts
I've experienced in my young development career.

*edit: spelling, and formatting.

~~~
carbon8
In addition, you can use something like the markdown filter for body text.

    
    
        :markdown
          ## Heading Content
          
          This is just some *emphatic* text. Maybe I'll talk about `$BASH_VERSION` here.

~~~
krainboltgreene
As someone who uses HAML constantly:

1\. :markdown doesn't accept classes, ids, or any other modifiers like %tags.
This makes for some difficult fugging.

2\. You cant do - ruby or = ruby under :markdown or similar.

This is terribly inconsistent and requires some stupid work arounds.

~~~
carbon8
1\. Discount, used by both RDiscount and BlueCloth, supports limited use of
classes in inline text via pseudo-protocols in link-style tags. You can also
use inline HTML in markdown. I believe that the latter is what most people do.

2\. You can do the equivalent of = in Haml filters by enclosing the Ruby in
#{}. For example, where _sign_up_path_ is a Ruby helper method:

    
    
        :markdown
          [Sign Up](#{sign_up_path})
    

Personally, in the past I've put large blocks of mostly-static content (eg, a
TOS) in a erb template or partial. I now often use the markdown filter for
things like help documentation in my sites.

~~~
krainboltgreene
The :markdown "symbol" doesn't take a class.

    
    
        :markdown.red#item2
    
        %list:markdown.red#item2
    
        %list.red#item2:markdown

...

~~~
carbon8
Forgive me if I'm misunderstanding your point, but :markdown isn't a tag that
gets output to html, it just designates the beginning of the block to be
processed with markdown, so classes and ids aren't applicable. If you want the
markdown block in a class or id, you just do this:

    
    
        #id.class
          :markdown
            [A link](/path)
    

outputs:

    
    
        <div id="id" class="class">
          <a href="/path">A link</a>
        </div>

------
jameskilton
The OP does know that HAML supports straight HTML as well right? The following
is perfectly valid:

%h2 Heading content

%p This is just some <em>emphatic</em> text. Maybe I'll talk about
<code>$BASH_VERSION</code> here.

Personally I'll never go back to writing straight HTML ever again. It's
ridiculously verbose, uses characters that are very hard to type, and it's
easy to forget to close a tag and not realize it.

------
roryokane
I don’t use Haml myself, but I have read that this is not how you are supposed
to write long text in it. The recommended way to write paragraphs with a lot
of tags is to use a filter, like Markdown or Textile. This is a better way to
write the sample paragraph in the article, using Markdown:

    
    
      %h2 Heading content
      %p
        :markdown
          This is just some *emphatic* text. Maybe I'll talk about `$BASH_VERSION` here.
    

Note that Markdown allows you to embed normal HTML tags within itself, in case
it doesn’t provide syntax for the tag you want. I’m not sure what the Haml
stance is on that practice.

------
railsjedi
Haml is great for structure, not for content. Chris Eppstein wrote a great
post on this that worth reading:

[http://chriseppstein.github.com/blog/2010/02/08/haml-
sucks-f...](http://chriseppstein.github.com/blog/2010/02/08/haml-sucks-for-
content/)

~~~
simplify
That's absolutely correct. I think too many people have a misconception of
what haml is good for.

Personally, I use haml for all my rails view layouts. Anything more
complicated than a wrapper div gets rendered in a separate .erb partial. This
makes it _very_ easy to shuffle around different parts of the layout when
needed.

------
zdw
Haml hits the wrong points for me as well:

\- Too much syntax for a pure writing markup languages, compared to Markdown
or Wiki syntaxes

\- Too little syntax compared to even syntax light languages like JSON or
[HT|X]ML (when written with zen coding or a tag matching editor)

It's just kind of awkward. Useful when embedded into rails, but not as a
general use markup language.

~~~
jdminhbg
Re: your first point, it's not a standalone markup language, it's a 1-to-1
replacement for HTML. Markdown is transformed into HTML, but doesn't have to
be -- you could PDF it instead, for instance. It's mostly just a way to use
structure to eliminate line noise.

------
adambard
Haml isn't really for what the author of this article was doing -- writing
actual prose. He has it right in the first paragraph: something like Markdown
is great for that sort of thing.

For displaying structured data, as one might do in a view in a web
application, Haml shines. Just think about table code.

Nobody with sense has ever said Haml is a great replacement for HTML in all
cases. But it's useful and (arguably) more pleasant to use within its domain.

------
JakeSc
Another complaint I have with HAML is its treatment of whitespace. Consider:

    
    
        %p
            %span.underlinedText this is underlined
        \.
     
     

This will underline " this is underlined ", with the spaces, which looks
messy. You can extrapolate this behavior to even messier cases, but you get my
point. HAML's solution is:

    
    
        %p
            %span.underlinedText><
                this is underlined
            %span><
                \.
    

Fun, right? However, I still consider HAML to be a beautiful replacement for
raw HTML.

------
koblas
I've wondered if haml is just a reaction to I don't like XML mindset, so we'll
invent a new syntax. Personally I like SASS, since it needed hierarchy
defined. But cleanly written HTML gives you that (yes, you need close tags,
but I already write closing parenthesis).

~~~
cheald
I resisted haml for a long time because of this; "HTML is good enough, why
change it?" and then I found out that it's really, really useful.

I'm currently dual-maintaining a theme in Wordpress and a Rails app; the
former is PHP with your standard interpolated HTML, and the latter is haml.
Guess which one is harder to maintain? (Hint: It's the Wordpress theme, by
about three hundred miles).

~~~
koblas
I personally found HTML + PHP a pain after playing django and it's template
model found it removed most of the pain that I was encountering.

------
petercooper
I don't "like" it either, but I don't think it sucks technically. A lot of
people find it useful and there's clearly value in the abstraction.

Where it fails for me is that I don't (rightly or wrongly) see (or treat) HTML
as a tightly structured language. Whereas tight formatting is beneficial for
languages with minimal syntax, like CSS, in HTML I appreciate the flexibility
of putting spacing and elements where I like or where I feel it makes sense
(but I love SASS/SCSS as it merely enhances an _already_ tightly structured
language). As ever, different strokes for different folks.

------
jcorcuera
You can use this if you prefer to use html for some stuff:

== <p>This is just some<em>emphatic</em> text. Maybe I'll talk about <code>
$BASH_VERSION </code></p>

Also exist 'plain' tag: :plain html stuff here another line easy :)

------
andrewvc
Haml's great for outlining the structure of a document. For static pages with
lots of em's strong's and such it's better to use something like markdown.
Luckily you can easily embed markdown inside HAML. Just mark off a block with
:markdown and you're done, you can put markdown in your HAML now.

No one language can give you everything, but haml's the best I've found AND it
makes it easier to mark certain areas as :plain, :erb, or :markdown or
whatever custom filter you dream up. So, it lets you switch more easily than
any other language when you need to.

------
davidw
I don't hate Haml, but I think HTML is ok as HTML, especially for those cases
where I want someone who is not a developer to work on a template.

------
pvxc
Wow, it's the second coming of Troff!

------
jarin
This article should be titled "I don't understand Haml".

Simple tags for ya buddy:

:plain

:textile

:javascript

------
trustfundbaby
> I should admit that I've used Haml for a total of about 15 minutes.

C'mon son.

------
bradgessler
Use both.

At Poll Ev we use erb for content and haml for "application" pages.

