PHPackages                             scil/mthaml-more - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. scil/mthaml-more

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

scil/mthaml-more
================

Add more features like snippet to MtHaml, one way to "Don't Reinvent the Wheel"

v0.7(11y ago)3183MITPHP

Since Aug 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/scil/MtHamlMore)[ Packagist](https://packagist.org/packages/scil/mthaml-more)[ Docs](https://github.com/scil/MtHamlMore)[ RSS](/packages/scil-mthaml-more/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (13)Used By (0)

MtHamlMore
==========

[](#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 `"scil/mthaml-more": "*"` to composer.json, see details at docs.

Main Feature :snip
------------------

[](#main-feature-snip)

if there is a box structure which is used many times, you can define it as a snip,for example

```
$box=$hamlfile,
        'reduce_runtime' => true,
));

```

'reduce\_runtime'=&gt;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:

```
%input(selected)

%input(selected=true)

%a(title="title" href=$href) Stuff

%script{:type => "text/javascript", :src => "javascripts/script_#{2 + 7}"}

%span.ok(class="widget_#{$widget['number']}")

.item{:class => $item['is_empty'] ? "empty":null}

%div.add{:class => [$item['type'], $item == $sortcol ? ['sort', $sortdir]:null] } Contents

#div{:class => array($item['type'], $item['urgency']), :id => array($item['type'], $item['number']>3?'big' :'small') }

%a{:data => array('author_id' => $data_id,'abc'=>array('ok'=>3,'no'=>$data_id+1))}

```

Not works

1. there is 'AttributeInterpolation' or 'AttributeList' in php files produced by MtHaml. I have not encounter this so far.
2. (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'

[](#option-reduce_runtime_array_tolerant)

The :class and :id attributes can be specified as a Ruby array, like

```
#div{:class => array($position,$item2['type'], $item2['urgency']), :id => array($item2['type'], $item2['number']>3?'big' :'small') }

```

if no one of $position, $item2\['type'\], $item2\['urgency'\] or $item2\['type'\] is an array, you could add ` 'reduce_runtime_array_tolerant'=>true,` 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

```
%div.add{:class => array($item['type'], $item == $sortcol ? array('sort', $sortdir):null) } Contents

```

- (add your needs in : MtHamlMore\\NodeVisitor\\PhpRenderer::maybeArrayReturnedNode)

Extra Feature 3 : prepare
-------------------------

[](#extra-feature-3--prepare)

if you set options 'prepare'=&gt;true , MtHamlMore will first execute php code defined by {% %} and {= =}.

like this:

```
{% $address='http://program-think.blogspot.com';$name='scil' %}
%div my name is {= $name =}, i love this IT blog {= $address =} which is blocked by GFW

```

executed to

```

%div my name is , i love this IT blog  which is blocked by GFW

```

then, to

```
%div my name is scil, i love this IT blog http://program-think.blogspot.com which is blocked by GFW

```

this is normal haml code,which will be compiled to

```
my name is scil, i love this it blog http://program-think.blogspot.com which is blocked by GFW

```

notice: {% .. %} must monopolize one line, because regular expression uses '^' and '$'.

code: MtHamlMore\\Environment::prepare

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~38 days

Recently: every ~1 days

Total

12

Last Release

4279d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f55c58baf3717e5aa4ec9ed3dc8770124a391975b72216c5e57d30fbf3b82f3?d=identicon)[scil](/maintainers/scil)

---

Top Contributors

[![scil](https://avatars.githubusercontent.com/u/2786775?v=4)](https://github.com/scil "scil (67 commits)")

---

Tags

HAMLsnippetmthaml

### Embed Badge

![Health badge](/badges/scil-mthaml-more/health.svg)

```
[![Health](https://phpackages.com/badges/scil-mthaml-more/health.svg)](https://phpackages.com/packages/scil-mthaml-more)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5973.6M93](/packages/roave-backward-compatibility-check)[coenjacobs/mozart

Composes all dependencies as a package inside a WordPress plugin

4753.9M23](/packages/coenjacobs-mozart)[v.chetkov/php-clean-architecture

PHP Clean Architecture

14659.9k](/packages/vchetkov-php-clean-architecture)[phpdocumentor/reflection

Reflection library to do Static Analysis for PHP Projects

12524.8M137](/packages/phpdocumentor-reflection)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
