related work
Next: license
Of course this is the original Ruby implementation just works. Go Ruby! http://haml-lang.com/alternative PHP implementations (attempts)
Summary: If there had been a working library I would not have spend days on writing this. So I can't seriously recommend any of those.
Don't miss Wikipedia's page about Haml
phphaml
flaws rev 90:
- Code does not pay attention to != vs &= vs =
- Code dose contain only one htmlentities which is used for quoting attribute values. So for HTML content no quoting is done at all!
phamlp
https://github.com/MarcWeber/phamlp
See my statement in the README. The parser will never be compliant without a rewrite. The author seems to be gone away ? No replies or updates for a long time.
Fammel
The idea was to use a proper Parser lexer and grammar. Current status: broken which the author admitted. To make it work maybe a lot of more work has to be done. So they assigned higher priorities to other projects meanwhile...
Probbaly fixing it is not that hard: You could approximate PHP expressions the way its done in this library by rewriting this recursive regex in the grammar:
// (?R) matches to most outer regexp recursively
// That's something Ruby can't do (yet?)
// You can't just parse until you hit a ","
// because contents can be %tag = substr(2,4,8)
// so the substr will be matched by "anything else", the (...) will be
// matched by the ", separated func args"
// keys are documentation only
$items = array(
'" str' => '"([^"\\]+|[\\].)*"',
"' str" => ''([^'\\]+|[\\].)*'',
', separated func args' => '(((?R)(,(?R))*))',
'recursion in ()' => '((?R))', // this catches nested ( 2 + (4 + ) ) ..
// '{(?R)}
' anything else but terminal' => "[^'"(){},n$s]+"
);
$regex ='('. implode('|',$items).')+';
phaml
- Qiuck and dirty minimal implementation
- less than 150 lines of code
- provides some interesting ideas
- parser based on regex (hard to maintain?)
- only a subset is supoprted in particular
- no quoting. You could workaround it by
-echo htmlentities($value);
- attributes are not handled the HAML way.
- no quoting. You could workaround it by
kohaml
kohaml quote from README: "This module is old and outdated and does not yet work for Kohana V3. Instead take a look at a better implementation by Fred Wu here - https://github.com/fredwu/kohana-phamlp". phamlp see above.
Link missing? Contact support
Next: license
