Tim Uckun wrote:
I tried HAML and got really frustrated by it.
That's too bad. I'm the main Haml developer, so I thought I'd try to
address some of the issues (even though this post is a month old... for
posterity, you know).
I could not find a way to put inline styles or inline javascript
(maybe it's possible but it was not in the docs).
You want filters - see the section of
http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml.html on filters.
The :plain filter will allow you to embed any sort of plain text in the
document, although you may prefer the :sass filter for CSS. For example:
%style{:type => "text/css"}
:sass
p
background-color: green
The same goes for Javascript. In the Haml master branch, there's also a
:javascript filter that wraps its content in script and CDATA tags.
It makes it very difficult to move sections of markup around. If you
want to move a table from one div to the next you have to practically
re-indent your entire page.
I sympathize, but the same is true for normal XHTML. Unless you're
willing to leave oddly-indented blocks of markup lying around your
document, it's just as much of a pain (more, if you can't end tags
). Also, a sufficiently smart text editor should be able to do this for
you.
If you make an error (and you will) the error message does not tell
you on which line you messed up. You have to examine the entire page
top to bottom to see where you messed up.
This is a bug in Haml that I've been working on fixing. I think
(*crosses fingers*) that it's been squashed in the master branch.
Joshua Muheim wrote:
One last thing: I read on several places that HAML was incredibly fast
compared to Markaby. Is that true?
Yes. Since Markaby's no longer maintained, there hasn't been nearly as
much optimization work put into it as into Haml. In addition, since it's
all Ruby code, there's no good way to cache partially-compiled templates
- this is where both Haml and ERB get most of their speed. In addition,
Markaby has to dynamically generate and append every bit of HTML, which
slows it down tremendously even in comparison to uncached ERB (the same
is true for Haml, but since it's cached it doesn't matter).
%p
Greetings,
= link_to(user.name, user_path(user))
!
Here's how I'd do it:
%p== Greetings, #{link_to(user.name, user_path(user))}!
<p>Greetings, <span class='some_class'>User</span>!</p>
The thing is, Haml isn't built for inline markup. Inline markup is a
very different beast than structural markup, and what works for
structure - namely, indentation - doesn't always work for inline. So
there's nothing wrong in dropping to a more inline-friendly syntax, like
XHTML:
%p== Greetings, <span class='some_class'>#{user.name}</span>!
Or even Textile:
:textile
%(class: some_class)#{user.name}%
Note the latter version will only work in the master branch, soon to be
released as Haml 2.0.