I'm considering Haml as a templating engine to use with PHP (via phammable).
Do you know any potential drawbacks to using it? Googling seems to glorify it too much, all that markup haiku thing.
The worst con against things like this is that your designers will have a hard time changing the layout. It all depends on team size, type of project, etc. But if it's only you that will be working with the layout files then just take whatever template system floats your boat in the end - it doesn't matter that much in the long run anyway.
Template 'languages' have a certain limit of helpfulness. The examples look good but it's never like that in the real cases.
If your templates are so complex that they need to be simplified by a 'template system' then you should try to reduce their complexity by feeding them simpler data structures and/or splitting your template in smaller partial templates.
In my opinion Haml is little useful even in Ruby version, but I agree that some may want to have everything in Ruyb, but it makes even less sense in PHP - the languages that was conceived with the purpose to work closely with HTML. I really see no benefits you could get from yousin PHP version of Haml. Why make simple thing complex?
Haml is best experienced by taking it for a test drive, feel how it rolls. Take a view and convert it to Haml. Try StaticMatic if you have Ruby installed, too. If you like how templates look like, use it -- because of yourself, not because of the hype.
But don't forget that the hype is here not by itself, but because Haml and Sass are pretty awesome.
I've been using Haml day after day for over a year. Before that I put in about five years of using JSP and PHP.
Use Haml.
One of the main advantages is that you can express exactly the same page structure and logic with much less code. In pure HTML and in "templating systems" based on it such as JSP, PHP, erb, etc., you have to type hundreds of <
and >
chars and additional chars to delimit areas of HTML from areas of programming language code. And you have to type opening and closing tags. Before long you wind up with a bewildering thicket of code that's painful and exhausting to maintain. But you sort of get used to it so after doing that for a while you kind of don't realize what a miserable experience the whole thing is.
Haml uses a much simpler system. You open a tag like this:
%p
Put stuff inside it like this:
%p
Bla bla bla.
That's a lot easier to type and to read than this:
<p>Bla bla bla</p>
What's inside of what is controlled by indentation:
%table
%tr
%td
Bla bla bla.
%td
%p
Hey now.
%p
Right on.
Include output from variables like this:
%p
= some_variable
It's not just easier because there are fewer characters. It's also easier because there are fewer weird characters that are hard to type. Might not sound like a big deal, but multiply "easier" by 10,000 times per day and it really makes a difference.
Haml is extremely easy to learn. The entire format is completely described on one page of their website. I picked it up in about 15 minutes. There are a few nuances that take a little more effort, but you can start doing useful work in Haml almost immediately.
Haml not really DRY that's why I make my own, W2tags and the demo is here, for example:
%ul
%li.menu.item menu 1
%li.menu.item menu 2
%li.menu.item menu 3
in my implementation I make a macro tag (!H!..) and use it:
!H!_li
%li.menu.item $0
%ul
-li menu 1;menu 2;menu 3
or you can code like this
%ul
-li menu 1;\
menu 2;\
menu 3