danjam/slim-mustache-view
最新稳定版本:1.1.2
Composer 安装命令:
composer require danjam/slim-mustache-view
包简介
Simple Slim 3 framework view renderer for mustache templates using Mustache.php
README 文档
README
Simple Slim 3 framework view renderer for mustache templates using Mustache.php
Install
Via Composer
$ composer require danjam/slim-mustache-view
Usage
// create Slim 3 app $app = new \Slim\App(); // get the container $container = $app->getContainer(); // register Mustache view $container['view'] = function ($container) { $view = new \Slim\Views\Mustache(); return $view; }; // define the route $app->get('/hello/{name}', function ($request, $response, $args) { return $this->view->render($response, 'Hello, {{name}}', [ 'name' => $args['name'] ]); }); // run the app $app->run();
The constructor takes an optional array of Mustache.php options. See the Mustache.php documentation for details.
// register Mustache view $container['view'] = function () { $view = new \Slim\Views\Mustache([ 'cache' => './cache/mustache', 'loader' => new Mustache_Loader_FilesystemLoader('./views'), 'partials_loader' => new Mustache_Loader_FilesystemLoader('./views/partials') ]); return $view; };
You can also capture raw template contents if needed. This can be useful for rendering inline templates, for example when also using mustache.js
$this->view->getRawTemplate('some-template.html');
Testing
phpunit
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 73.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-25