nod.st/cakephp-mustache

There is no license information available for the latest version (v0.0.4) of this package.

Simple CakePHP View Helper Plugin for the Mustache template assets

Installs: 16

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Type:cakephp-plugin

v0.0.4 2013-09-06 18:58 UTC

This package is not auto-updated.

Last update: 2024-04-23 02:56:30 UTC


README

A helper for configuring and wrapping methods for the Mustache template engine.

Configuring

Install it from command line with the Composer in your project:

composer require nod.st/cake-mustache

Load the plugin in your:

<?php
//./Config/bootstrap.php
CakePlugin::load(array(
    'CakeMustache'  => array(
        'bootstrap' => true
    )
));
?>

Add it to a Controller: (Note: Below option values are default settings, and you don't need to pass them as long as you would like to change it.)

<?php
//./Controller/AppController.ctp
class AppController extends Controller {
    public $helpers = array(
        'CakeMustache.Mustache' => array(
            'path'          => './../webroot/mustache',
            'extension'     => 'mustache',
            'viewVariables' => true
        )
    );
}
?>

Optionally you can also change set the path with Configure class with:

<?php
//For example, ./Config/bootstrap.php
Configure::write('Mustache.path', '/my/custom/and/awesome/folder/path/to/mustache/templates');
?>

Create some mustache templates for being sure it's working:

<!-- ./webroot/mustache/test.mustache -->
<p>Test1: {{text}}</p>
{{> test2}}
<!-- ./webroot/mustache/test2.mustache -->
<p>Test2: {{text}}</p>

You can now render the template on your views:

<?php
//./View/Layouts/default.ctp
echo $this->Mustache->render('test.mustache', array(
    'text'  => 'Hello Mustache!'
));
?>

Is it working? Awesome! No? Then you're welcome to create an issue with some details.