Question

Is anyone using a HAML implementation for PHP like phpHaml or pHAML? Both projects have seen no activity for about 2 years, and both are < 1.0. Is it feasible/wise to use HAML for a large PHP application, or is it too immature?

Does anybody have experience with Chaml for CakePHP? I played around with it, and it seems to be really picky about whitespace, which I think might cause a few hiccups in a large project with many developers.

I really want to use HAML or something minimalistic like it, but I don't want it to add another layer of debugging problems. Recommendations are welcome.

Was it helpful?

Solution

Oh well, so in the meantime, I did start writing a small site using Chaml, which uses the phpHaml parser. First of all: HAML is so much fun! X-D

Second: phpHaml is still a little buggy. I've had instances where a line like

= $html->link('Something', '/somewhere')

yielded

<?php echo $html->link('Something', '/somewhere'); ?><?php echo $html->link('Something', '/somewhere'); ?>

if the following line was left blank. Inserting something on the following line removed the duplicate. This means you're always required to double check you're actually producing the markup you think you are.

The Chaml plugin is working quite well, I haven't had any particular problems with it. The included SASS parser is not really worth talking about though, it's experimental at best.

Overall, HAML on PHP at this stage does add a slight debugging overhead, so I wouldn't recommend using it to just anybody. It may be worth it if you'd have to type loads and loads of markup otherwise.

I'm currently trying to decide whether diving into the phpHaml parser or switching to Rails is the better decision. ;)

OTHER TIPS

My expertise is not with HAML but with CakePHP so I can only answer part of your question. CakePHP is a tightly coupled framework so you either work with it or against it. If you wanted to use a different template engine such as HAML you'd be better with a loosely coupled framework such as Code Igniter or Zend.

For more information see this thread on using Smarty in Code Igniter or Zend - the same principle would apply for using HAML.

See: http://haml-to-php.com/related%20work.html. It depends on how much of the HAML features you want to use. Most of them get simple HAML right. But if you also want have quoting and maybe advanced features such as %div{:attr=>"foo_#{ php code }"} all but HAML-TO-PHP fail to my knowledge

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top