Mustache templates
Implements Mustache templates in PHP files. Install vendor from Composer and config the FilesystemLoader option, and change the file extensoin from .mustache to .html; Create and put the templates on folder /views and the partials on /views/partials.
vendor
composer require mustache/mustache
example
PHP file
require __DIR__ . '/vendor/autoload.php'; $options = [ 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views', ['extension' => '.html']), 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/views/partials', ['extension' => '.html']) ]; $mustache = new Mustache_Engine($options); $template1 = $mustache->loadTemplate('test'); echo $template1->render(['planet' => 'World', 'txt' => 'yeah!']);
Template: /views/test.html
<h1>Hello {{planet}}</h1> <h2>{{>test2}}</h2>
Partial template: /views/patials/test2.html
hell {{txt}}