I Hate Haml
ithaca.arpinum.org
ithaca.arpinum.org
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.
PS - You spelled "flame-bait" wrong.
PS - Pointing out my misspelling of "flame-bait" is flame-bait.
So hey, to make something of this discussion: Am I correct in thinking HAML is fairly closely tied to Ruby? I'm quite familiar with Markdown* , but don't use Ruby. As long as we're committing to a given language for an ersatz HTML syntax, I prefer CL-WHO (http://weitz.de/cl-who/) or a similar approach in Lua, JSON, etc.
Also, it doesn't look like there's cross-language support, which is a major advantage for Markdown, JSON, and other such formats.
* My favorite implementation is discount (http://www.pell.portland.or.us/~orc/Code/discount/), which is written in C, quite fast, and has a good test suite and pretty clean API.
%div{:class => [ruby code here]}
Although there are PHP ports out there in progress.
There is also a Ruby Discount gem, rdiscount.
No doubt, except that I hate Haml. You're absolutely right that it was a quick sloppy post on my part. That said, I stand by my feelings (as personal reactions to how Haml looks and the choices it makes) and the HTML2Haml site suggested (by implication of how it converts things) that newlines was the way to do it. I absolutely didn't realize that you could include straight HTML inside Haml (and the docs don't make this overwhelmingly obvious). I now see this in the docs under "Plain Text":
> Note that HTML tags are passed through unmodified as well. If you have some HTML you don’t want to convert to Haml, or you’re converting a file line-by-line, you can just include it as-is.
But I wasn't looking in the section on "Plain Text" since I wanted marked-up text. Still, my fault for not reading the docs more carefully before ranting.
Thanks for the tip and response (to you and to everyone here). I'm updating the post now. Changes should go up in no more than an hour. Edit: Changes are live. Thanks again to all commenters.
:markdown
## Heading Content
This is just some *emphatic* text. Maybe I'll talk about `$BASH_VERSION` here.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.
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. :markdown.red#item2
%list:markdown.red#item2
%list.red#item2:markdown
... #id.class
:markdown
[A link](/path)
outputs: <div id="id" class="class">
<a href="/path">A link</a>
</div>2. It would be deadly easy to have inline markup. Say: %p La la %strong la % la la.
3. The whole point of using HAML is to get rid of using the annoying HTML syntax. (Remember the tagline 'Markup haiku'?
%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.
%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.http://chriseppstein.github.com/blog/2010/02/08/haml-sucks-f...
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.
- 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.
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.
%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.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).
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.
== <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 :)
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.
Simple tags for ya buddy:
:plain
:textile
:javascript
C'mon son.
At Poll Ev we use erb for content and haml for "application" pages.