Hi,
I guess the biggest difference is that YiiML says it "is inspired by Haml and Sass".
By contrast PHamlP is Haml and Sass.
Because PHamlP is Haml and Sass you may get a better answer by asking the creator of YiiML what the differences are between it and Haml/Sass.
There are two differences from PHamlP from standard Haml and Sass:
[list=1]
[*]code blocks in Haml and code interpolation in both is PHP, not Ruby (but you knew that already )
[*]PHamlP can use tabs or spaces for indentation and automatically detects which
[/list]
The extension simply provides the interfaces for Yii to use Haml and Sass and so is kind of two in one as Haml and Sass are independent of each other, i.e. in your application you can use Haml without Sass or Sass without Haml; of course you can use both .
Personally I use both. I find using Haml tidies up my views and using indentation really makes the structure of the document easy to manage.
But the big win is Sass. Nesting keeps the code clean and readable, variables make the code more maintainable, and mixins (together with includes) make it modular, and Sass parses a Sass file and all its includes to a single CSS file to keep down the number of requests to the server.
In each there are various rendering options; for development there is the human readable "nested" renderer, and for production there is the "compressed" renderer that removes as much whitespace as it can to keep file sizes to a minimum. All done on the fly and cached to keep processing to a minimum (you can turn caching off BTW).
Contrary to the statements in the YiiML thread, Haml does provide flow control and PHamlP uses PHP syntax, e.g.
- if($this)
.if-div do that
- else
.else-div do something else
parses to
<?php if($this){ ?>
<div class="if-div">
do that
</div>
<?php } else { ?>
<div class="else-div">
do something else
</div>
<?php } ?>
All the control flow structures are supported (if, else, elseif, foreach, do, and while). The only one that is perhaps a little different is "do" because the "while" statement is expressed with the "do" clause, i.e.
%ul
- do($i--)
%li= $i
parses to:
<ul>
<?php do { ?>
<li>
<?php echo $i; ?>
</li>
<?php } while($i--); ?>
</ul>
It seems YiiML has a different syntax from Haml. PHamlP uses the Haml and Sass syntaxes, so PHamlP documentation is the Haml and Sass documentation.
YiiML also says "but it’s really [Haml] quite focused on views, and keeping logic inside helpers/controllers". Yes it is and that is where things should be.
If you need to extend Haml this can be done by writing and using a filter, but MCV principles should be adhered to. Most of the standard Haml filters (:ruby becomes :php; there are not equivalents for :erb, :textile, or :marku; the :markdown filter is Yii specific) are bundled with PHamlP. If anyone writes others I would be interested in adding them as optional downloads.
So, for example, you can put raw PHP code in the view using the PHP filter:
:php
foreach ($values as $key=>$value) {
$value = $value * 2;
}
What I don’t see in YiiML is CSS or Sass support (that probably means I didn’t find it, not that it’s not there).
I hope this goes some way to answering your question.