nod.st/cakephp-mustache
Composer 安装命令:
composer require nod.st/cakephp-mustache
包简介
Simple CakePHP View Helper Plugin for the Mustache template assets
README 文档
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.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2013-09-06