Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A mustache parser with extended functionality written in PHP.
tree: 0f6fe154e9

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Mustache Extended

Mustache Extended is a mustache-like template renderer with some extra functionality. Some things like partials and lambdas have been removed.

Basic usage


$renderer = new \Mustache\Renderer();
echo $renderer->render('Hello {{who}}', array(
    'who' => 'world'


One way to use filters is with variables:


This code will first apply filter myfilter on variable myvar and then display the the result. You can also use multiple filters on a variable. In that case the filters would be executed from left to right.

It is also possible to use filters with blocks. You can find an example for doing so below.

Creating your own filters

class Bold extends \Mustache\Filter
    public $name = 'bold';

    public function filter ($data)
        return '<strong>' . $data . '</strong>';

\Mustache\Filter::register(new Bold());

Built-in filters


Using this filter will prevent the engine from automatically escaping the variable. This has no effect on blocks.


This filter will convert the variable into a boolean value. This can be especially useful when used with blocks:

    Some problems were found:
        {{.}}<br />

With the following dataset:

    'problems' => array(
        'Lorem ipsum dolor sit amet',
        'Donec ut imperdiet lorem'
Something went wrong with that request. Please try again.