Download the PHP package scil/mthaml-more without Composer
On this page you can find all versions of the php package scil/mthaml-more. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scil/mthaml-more
More information about scil/mthaml-more
Files in scil/mthaml-more
Package mthaml-more
Short Description Add more features like snippet to MtHaml, one way to "Don't Reinvent the Wheel"
License MIT
Homepage https://github.com/scil/MtHamlMore
Informations about the package mthaml-more
MtHamlMore
Add some features like snippet to MtHaml, main purpose is “Don't Reinvent the Wheel".
Both php and Twig are supported.
Install method: add to composer.json, see details at docs.
Main Feature :snip
if there is a box structure which is used many times, you can define it as a snip,for example
write haml like so:
output html :
'@@@' is a placeholder where you can put your own content,and you could define default value for it, or even set global placeholder default value use option 'globalDefaultPlaceholderValue', that's useful if you want all placeholder rendered to empty string when you forget apply placeholder value.
second example: inline placeholder snips:
haml:
output:
third example
This is calling a snip named grid, and two arguments. Usually, I use snip @grid to define grid layout. 'fluid="1"' is fluid layout, 'grid="4 -4 4" is one type of 12 columns grid. What this statement output depends on how your snip writes. In 'examples/snips/php.php', there is an snip which defines Twitter Bootstrop v2 grid. In case of this,output would be
Attribute values can be writed as named placeholdervalue
is equal with
Please note, this form is not treated as attribute value
And
equals with
see more examples at : "docs/0. Snip Examples.md"
Extra Feature 1 : HtmlTag
html tags can be used like haml tag ,not only
which is supported by MtHaml, but also
This feature enables you to copy any html code into a haml file, only make sure code apply haml indent syntax.
code: MtHamlMore\Parser::parseHtmlTag
Extra Feature 2 : reduce runtime
Sometimes there are some 'MtHaml\Runtime' in php files produced by MtHaml, if you dislike it ,you may try
'reduce_runtime'=>true could reduce the appearance of 'MtHaml\Runtime',or replace it with \MtHamlMoreRuntime\Runtime::renderAttribute which is much simpler.
It's not perfect,but works in normal situation.
Works well for these haml:
Not works
-
there is 'AttributeInterpolation' or 'AttributeList' in php files produced by MtHaml. I have not encounter this so far.
- (welcome add your find)
This feature supported only for php ,not Twig.
code:
- MtHamlMore\NodeVisitor\PhpRenderer::renderDynamicAttributes
- MtHamlMoreRuntime\Runtime::renderAttribute
option 'reduce_runtime_array_tolerant'
The :class and :id attributes can be specified as a Ruby array, like
if no one of $position, $item2['type'], $item2['urgency'] or $item2['type'] is an array, you could add to 3rd argument of compilePhpMoreHaml. Then array flatten is not needed in this case.
code: MtHamlMore\NodeVisitor\PhpRenderer::returnJoinedValueForClassId
when option 'reduce_runtime_array_tolerant' is true , only these situations will use array flatten right now:
-
if or else is an array in 'condition?if:else',like
- (add your needs in : MtHamlMore\NodeVisitor\PhpRenderer::maybeArrayReturnedNode)
Extra Feature 3 : prepare
if you set options 'prepare'=>true , MtHamlMore will first execute php code defined by {% %} and {= =}.
like this:
executed to
then, to
this is normal haml code,which will be compiled to
notice: {% .. %} must monopolize one line, because regular expression uses '^' and '$'.
code: MtHamlMore\Environment::prepare
All versions of mthaml-more with dependencies
phpunit/phpunit-story Version 1.*
nikic/php-parser Version 1.*@dev