• Stars
    star
    3,202
  • Rank 14,019 (Top 0.3 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 14 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Mustache implementation in PHP.

Mustache.php

A Mustache implementation in PHP.

Package version Build status StyleCI Monthly downloads

Usage

A quick example:

<?php
$m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES));
echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!"

And a more in-depth example -- this is the canonical Mustache template:

Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well, {{taxed_value}} dollars, after taxes.
{{/in_ca}}

Create a view "context" object -- which could also be an associative array, but those don't do functions quite as well:

<?php
class Chris {
    public $name  = "Chris";
    public $value = 10000;

    public function taxed_value() {
        return $this->value - ($this->value * 0.4);
    }

    public $in_ca = true;
}

And render it:

<?php
$m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES));
$chris = new Chris;
echo $m->render($template, $chris);

Note: we recommend using ENT_QUOTES as a default of entity_flags to decrease the chance of Cross-site scripting vulnerability.

And That's Not All!

Read the Mustache.php documentation for more information.

See Also

More Repositories

1

psysh

A REPL for PHP
PHP
9,637
star
2

git-flow-completion

Bash, Zsh and fish completion support for git-flow.
Shell
2,783
star
3

genghis

The single-file MongoDB admin app
Ruby
1,452
star
4

Ruler

A simple stateless production rules engine for modern PHP
PHP
1,025
star
5

Faker

The easiest way to generate fake data in PHP.
PHP
187
star
6

solarized-seestyle

A precision color scheme for Coda and SubEthaEdit with light and dark modes
99
star
7

Mustache.mode

Mustache syntax mode for Coda and SubEthaEdit.
HTML
90
star
8

coda-cli

Makes Panic's Coda a first-class *nix citizen
Python
53
star
9

vagrant-mongobox

A simple little Vagrant box for running MongoDB
Puppet
51
star
10

Markdown.mode

A Markdown syntax mode file for Coda and SubEthaEdit.
40
star
11

Population

A simpler way to populate your Doctrine 2 databases.
PHP
37
star
12

coda-modes

A curated collection of syntax modes for Coda and SubEthaEdit.
35
star
13

Twig-HTML.mode

A Twig syntax mode for Coda and SubEthaEdit.
30
star
14

PHP-HTML.mode

A fork of Coda 1.x's PHP-HTML syntax mode. Doesn't work with 2.x :(
Perl
22
star
15

launchctl-completion

Bash completion support for OS X launchctl.
Shell
19
star
16

BobthecowMustacheBundle

Symfony2 + mustaches.
PHP
17
star
17

googlecl-completion

Bash completion support for googlecl.
Shell
15
star
18

copyonclick

A copyOnClick plugin for jQuery.
JavaScript
14
star
19

mustache-silex-provider

Mustache integration for the Silex application micro-framework.
PHP
14
star
20

GitX.codaplugin

This Coda plugin integrates Coda with GitX.
13
star
21

codaclips

A simple import/export script for Coda clips.
Shell
12
star
22

sublime-sniptastic

A quick and dirty snippet palette for Sublime Text 2.
Python
12
star
23

apprise-bootstrap

Stylish alerts for a Bootstrapped web.
JavaScript
11
star
24

heroku-buildpack-nanoc

ApacheConf
8
star
25

Twig-JavaScript.mode

A Twig (+JavaScript) syntax mode for Coda and SubEthaEdit.
7
star
26

CodaDocblock

Generate PHP Docblocks like magick!
Python
7
star
27

Gity.codaplugin

This Coda plugin integrates Coda with Gity, a sweet little Git client for OS X.
6
star
28

terminitor-completion

Bash completion support for terminitor.
Shell
6
star
29

forematter

The frontmatter-aware friend for your static site.
Ruby
6
star
30

ManipulateCoda

A text manipulation plug-in for Panic’s Coda
Python
5
star
31

homebrew-php

PHP formulae repo for Homebrew
Ruby
4
star
32

Twig-XML.mode

A Twig (+XML) syntax mode for Coda and SubEthaEdit.
4
star
33

genghisapp.com

This is the repo of the site of the app Genghis.
JavaScript
3
star
34

psysh.org

A website for a REPL for PHP
JavaScript
2
star
35

gist.codaplugin

Coda plugin utilizing gist.rb
2
star
36

psysh-mongodb

A MongoDB Plugin for PsySH
PHP
2
star