Skip to content

Wikia/php-mustache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-mustache

GitHub 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.

See also: template loader example

Credits

License

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

Packages

No packages published

Languages

  • C++ 60.8%
  • PHP 24.6%
  • Nix 8.0%
  • M4 6.6%