English 中文(简体)
Feasibility of HAML + PHP/CakePHP
原标题:

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.

最佳回答

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

问题回答

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





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签