PHPackages                             savageman/zenml - 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. savageman/zenml

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

savageman/zenml
===============

Converts Hamlbar-like string to Handlebars template

013PHP

Since Jan 30Pushed 12y ago2 watchersCompare

[ Source](https://github.com/Savageman/zenml)[ Packagist](https://packagist.org/packages/savageman/zenml)[ RSS](/packages/savageman-zenml/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

ZenML
=====

[](#zenml)

I love Handlebars, but I find it still lacks indentation-based DOM tree (like Haml) &amp; Emmet/CSS syntax for ID and classes.

So I made this pre-processor to solve the problem. It generates Handlebars.

Quick guide
-----------

[](#quick-guide)

- A line containing an HTML tag starts with `%` ;
- Indentation is used to create the DOM tree ;
- Indentation also works for Handlebars `{{#helpers}}` ;
- Attributes are added using the regular HTML syntax: `title="This is the title"` ;
- Text node can be added either:
    - On a new line using indentation
    - As a `text` attribute of the current tag: `text="This is my text"`
- Any unrecognised line is interpreted as plain-text.

Example
-------

[](#example)

```
%h1 text="This is my title"

%div #container

    {{ #each items }}
        %h2 text="{{title}}"
        %span .date text="{{date}}"
        %div .description
            The description is a bit longer,
            so I split it on several lines.

    {{ else }}
        %p text="Nothing here..."

%footer
    This is the end of the example.

```

is converted into:

```
This is my title

    {{#each items}}
        {{title}}
        {{date}}

            The description is a bit longer,
            so I split it on several lines.

    {{else}}
        Nothing here...
    {{/each}}

    This is the end of the example.

```

Usage
-----

[](#usage)

```
$template =  '',
    'input_indentation' => '    ',
    'output_indentation' => '    ',
));

echo htmlspecialchars($zenml->render($template));
```

Limitations
-----------

[](#limitations)

(I'll be glad if people could help me out sorting these out.)

- You must put a space between the tag name and each CSS-like `#id` and `.classes` attributes ;
- Text node must be on a new line (it would be nice to allow it at the end of the line) ;
- Only one tag per line.

Todo
----

[](#todo)

- Include some examples using [voodoophp/handlebars](https://www.github.com/mardix/Handlebars)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/258c5e1bac9309bebead1638e36b5e1cc12d7351f09916f0bbbe034a78995984?d=identicon)[Savageman](/maintainers/Savageman)

---

Top Contributors

[![Savageman](https://avatars.githubusercontent.com/u/183785?v=4)](https://github.com/Savageman "Savageman (16 commits)")

### Embed Badge

![Health badge](/badges/savageman-zenml/health.svg)

```
[![Health](https://phpackages.com/badges/savageman-zenml/health.svg)](https://phpackages.com/packages/savageman-zenml)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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