1

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.

deceze
  • 510,633
  • 85
  • 743
  • 889

3 Answers3

3

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. ;)

deceze
  • 510,633
  • 85
  • 743
  • 889
0

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.

Community
  • 1
  • 1
Mathew Attlee
  • 549
  • 1
  • 4
  • 15
  • deceze is intimately familiar with cakephp from the history of answers he has provided and his reputation score. – Abba Bryant Dec 04 '09 at 15:55
  • I just noticed that I did overlook the existence of Chaml in the original question, however my answer still remains in that it is more feasible to replace the view system in a loosely coupled framework. – Mathew Attlee Dec 04 '09 at 17:59
  • It's really not such a big deal to replace the View layer in Cake by subclassing View and setting `var $view = 'MyView';` in AppController, hence that wasn't the important part of the question. :) – deceze Dec 05 '09 at 01:24
0

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

Marc Weber
  • 511
  • 4
  • 3