PHPackages                             alexvasilyev/mthaml - 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. [Templating &amp; Views](/categories/templating)
4. /
5. alexvasilyev/mthaml

ActiveLibrary[Templating &amp; Views](/categories/templating)

alexvasilyev/mthaml
===================

HAML for PHP

1.9.1(8y ago)18011MITPHPPHP &gt;=5.4.0

Since May 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alexvasilyev/MtHaml)[ Packagist](https://packagist.org/packages/alexvasilyev/mthaml)[ Docs](https://github.com/arnaud-lb/MtHaml)[ RSS](/packages/alexvasilyev-mthaml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (18)Used By (1)

Multi target HAML
=================

[](#multi-target-haml)

[![Build Status](https://camo.githubusercontent.com/4637ae1619da03c98022e6c9e7e53ef25e5446224a66e431c504fbabb2f88552/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f61726e6175642d6c622f4d7448616d6c2e706e67)](http://travis-ci.org/arnaud-lb/MtHaml)

MtHaml is a PHP implementation of the [HAML language](http://haml-lang.com/) which can target multiple languages.

Currently supported targets are PHP and [Twig](http://www.twig-project.org/), and new ones can be added easily.

Mt-Haml implements the exact same syntax as ruby-haml; the only difference is that any supported language can be used everywhere HAML expects Ruby code:

HAML/Twig:
----------

[](#hamltwig)

```
%ul#users
  - for user in users
    %li.user
      = user.name
      Email: #{user.email}
      %a(href=user.url) Home page
```

Rendered:

```

  {% for user in users %}

      {{ user.name }}
      Email: {{ user.email }}
      Home page

  {% endfor %}

```

HAML/PHP:
---------

[](#hamlphp)

```
%ul#users
  - foreach($users as $user)
    %li.user
      = $user->getName()
      Email: #{$user->getEmail()}
      %a(href=$user->getUrl()) Home page
```

Rendered:

```

      Email:
