Skip to content
Mustache PHP Extension
Branch: master
Clone or download
Latest commit 06be417 Nov 14, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci Improve CI configuration Nov 14, 2018
spec @ 72233f3 Should fix #2 Jun 28, 2013
tests Remove the compiler and VM Nov 9, 2018
.editorconfig
.gitignore Improve CI configuration Nov 14, 2018
.gitmodules
.travis.yml
LICENSE.md Update license and readme Oct 5, 2015
README.md
appveyor.yml
ax_cxx_compile_stdcxx_11.m4
bench.php Fixed compile issues without C++11 Jul 30, 2013
config.m4 Remove the compiler and VM Nov 9, 2018
config.w32 Fix appveyor Nov 11, 2018
default.nix Change default.nix to use the local path by default Nov 11, 2018
derivation.nix
generate-tests.php Lambda support Oct 15, 2015
mustache.php Remove the compiler and VM Nov 9, 2018
mustache_ast.cpp
mustache_ast.hpp Appveyor (#44) Aug 3, 2017
mustache_class_method_lambda.cpp Appveyor (#44) Aug 3, 2017
mustache_class_method_lambda.hpp Remove execute bit Mar 18, 2016
mustache_data.cpp fix for PHP 7.3 and Array/Object recursion protection Jun 28, 2018
mustache_data.hpp Appveyor (#44) Aug 3, 2017
mustache_exceptions.cpp
mustache_exceptions.hpp Appveyor (#44) Aug 3, 2017
mustache_lambda.cpp Appveyor (#44) Aug 3, 2017
mustache_lambda.hpp Appveyor (#44) Aug 3, 2017
mustache_lambda_helper.cpp
mustache_lambda_helper.hpp Appveyor (#44) Aug 3, 2017
mustache_mustache.cpp Remove the compiler and VM Nov 9, 2018
mustache_mustache.hpp
mustache_private.hpp
mustache_template.cpp Appveyor (#44) Aug 3, 2017
mustache_template.hpp PHP 7 support Jul 23, 2015
mustache_zend_closure_lambda.cpp Appveyor (#44) Aug 3, 2017
mustache_zend_closure_lambda.hpp
package.xml Release v0.8.1 Nov 12, 2018
php5to7.h
php_mustache.cpp Remove the compiler and VM Nov 9, 2018
php_mustache.h
test_mem.sh PHP 7 support Jul 23, 2015

README.md

php-mustache

Build Status Build status Coverage Status Software License

C++ implementation of Mustache as a PHP extension.

Features

All features of Mustache are supported EXCEPT:

  • Whitespace rules. All whitespace is kept as it is in the input template.

Installation

Linux/OSX

Source

Prerequisite packages are:

  • PHP development headers and tools
  • gcc >= 4.4 | clang >= 3.x | vc >= 11
  • GNU make >= 3.81
  • automake
  • autoconf
  • libmustache
git clone git://github.com/jbboehr/php-mustache.git --recursive
cd php-mustache
phpize
./configure --enable-mustache
make
sudo make install

Add the extension to your php.ini:

echo extension=mustache.so | tee -a /path/to/your/php.ini

Fedora/RHEL/CentOS

RPM packages of the extension are available in Remi's repository.

Fedora (change 24 to match your Fedora version)

dnf install https://rpms.remirepo.net/fedora/remi-release-24.rpm
dnf install --enablerepo=remi php-pecl-mustache

RHEL/CentOS (for default PHP in base repository)

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install php-pecl-mustache

Nix/NixOS

nix-env -i -f https://github.com/jbboehr/php-mustache/archive/master.tar.gz

Windows

See Build your own PHP on Windows. You may need to add msinttypes (export) to your include directory.

Usage

Example:

<?php
$mustache = new Mustache();
$tmpl = <<<EOF
Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well, {{taxed_value}} dollars, after taxes.
{{/in_ca}}
EOF;
$data = array(
  'name' => 'John',
  'value' => 10000,
  'taxed_value' => 10000 * 0.6,
  'in_ca' => true,
);
$partials = array();
echo $mustache->render($tmpl, $data, $partials);

Produces:

Hello John
You have just won 10000 dollars!

Well, 6000 dollars, after taxes.

Credits

License

The MIT License (MIT). Please see License File for more information.

You can’t perform that action at this time.