tags:

views:

341

answers:

2

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.

A: 

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.

Mathew Attlee
deceze is intimately familiar with cakephp from the history of answers he has provided and his reputation score.
Abba Bryant
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
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
+2  A: 

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