Tim U. 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 M. 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))}!
Greetings, User!
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, #{user.name}!
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.