PHPackages                             electblake/mustache - 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. electblake/mustache

ActiveCakephp-plugin

electblake/mustache
===================

CakePHP View Helper Plugin for the Mustache Templating Language

14386[2 issues](https://github.com/electblake/CakePHP-Mustache-Plugin/issues)PHP

Since Mar 16Pushed 13y ago4 watchersCompare

[ Source](https://github.com/electblake/CakePHP-Mustache-Plugin)[ Packagist](https://packagist.org/packages/electblake/mustache)[ RSS](/packages/electblake-mustache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CakePHP (2.x) Mustache Plugin
=============================

[](#cakephp-2x-mustache-plugin)

Mustache View helper (*originally CakePan*) that renders Mustache templates. It will also load and process partials!

### Why use Mustache templates in CakePHP?

[](#why-use-mustache-templates-in-cakephp)

**Portability and scalability!** If you have an app that uses lots of front-end coding, you only have to write your templates once. Mustache templates can be rendered in PHP, Javascript, Ruby, Scala, even C++! If you want to move to or from some other framework (Rails, Grails, Lithium etc.), you can be sure that your views and design won't have to be re-built.

For scalability, when the time comes, you can use templates with a more powerful engine like Scala, or just send JSON from any source, and render with Javascript.

Installation
------------

[](#installation)

### 1. From app directory - `git submodule add git@github.com:electblake/CakePHP-Mustache-Plugin.git Plugin/Mustache`

[](#1-from-app-directory---git-submodule-add-gitgithubcomelectblakecakephp-mustache-plugingit-pluginmustache)

### 2. cd into Plugin/Mustache (so we can pull in the latest php implementation of mustache into Plugin/Mustache/Vendor)

[](#2-cd-into-pluginmustache-so-we-can-pull-in-the-latest-php-implementation-of-mustache-into-pluginmustachevendor)

### 3. `git submodule init`

[](#3-git-submodule-init)

### 4. `git submodule update`

[](#4-git-submodule-update)

If you want to add Mustache support globally, add it to your `AppController`

```
class AppController extends Controller {
	...
	public $helpers = array('Mustache.Mustache');
	...
}

```

Usage
-----

[](#usage)

See the Mustache manual:

### Creating a Mustache Template

[](#creating-a-mustache-template)

Your Mustache templates should all be in the `/app/View/Elements/` directory, with a `.mustache` extension.

/app/View/Elements/post.mustache

```
{{#Post}}
{{title}}

	{{text}}

{{/Post}}

```

### Rendering a Mustache Template

[](#rendering-a-mustache-template)

All the variable set by the controller are available, and merged with values passed into `$params`.

```
$params = array(
	'title' => 'Show me the bacon!',
	'text' => 'Bacon ipsum dolor sit amet fatback pig swine...'
);

$this->Mustache->render('template_name', $params)

```

### Using Partials

[](#using-partials)

Partials should follow the same naming convention. Mustache will pass the variables to the partial in the context that it's called. For example, a nested template for a blog `post` with `comments` might look like:

/app/View/Elements/posts/post.mustache:

```
{{#Post}}
{{title}}

	{{text}}

{{/Post}}
{{#Comment}}
	{{>post/comment}}
{{/Comment}}

```

/app/View/Elements/posts/comment.mustache:

```

{{#User}}{{name}}{{/User}} said:
{{text}}

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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/2e0124bf77b27267de2669fe77779c6b2a941a20f1e33374ef5d692e7a85b128?d=identicon)[electblake](/maintainers/electblake)

---

Top Contributors

[![bwiggs](https://avatars.githubusercontent.com/u/7358?v=4)](https://github.com/bwiggs "bwiggs (16 commits)")[![electblake](https://avatars.githubusercontent.com/u/22871?v=4)](https://github.com/electblake "electblake (13 commits)")[![andrewdrane](https://avatars.githubusercontent.com/u/58255?v=4)](https://github.com/andrewdrane "andrewdrane (5 commits)")[![Hendler](https://avatars.githubusercontent.com/u/144833?v=4)](https://github.com/Hendler "Hendler (2 commits)")

### Embed Badge

![Health badge](/badges/electblake-mustache/health.svg)

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

PHPackages © 2026

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