lejahmie/slim-mustache-view
Composer 安装命令:
composer require lejahmie/slim-mustache-view
包简介
Mustache View package for the Slim Framework
README 文档
README
Mustache View package for the Slim Framework 3+, using bobthecow great PHP implementation of Mustache! ;-)
How to install
Using Composer
$ composer require lejahmie/slim-mustache-view
How to use
<?php require 'vendor/autoload.php'; $app = new \Slim\Slim(); $container = $app->getContainer(); $container['view'] = function ($c) { $mustache = new \Slim\Mustache\Mustache( '/templates', // Template path array( 'charset' => 'UTF-8', ), array( 'extension' => '.html' ) ); return $mustache; }; $app->get('/', function (Request $request, Response $response) { // The render method takes the reponse object, // template name and finally some data as an array. $response = $this->view->render($response, "hello", ["foo" => 'bar']); return $response; });
Methods
render($templateName, $data)
Renders the Mustache template with the ResponseInterface used by Slim; $response->getBody()->write($output);
getRenderedMarkup($templateName, $data)
Returns the renderd Mustache template as a string.
setTemplatePath($templatePath)
Set the template path where Mustache will look for template files.
setLoaderOptions($loaderOptions)
Set the options for Mustache filesystem loader. See; https://github.com/bobthecow/mustache.php/wiki/Template-Loading
setOptions($options)
Set the Mustache options. See; https://github.com/bobthecow/mustache.php/wiki
Authors
License
The MIT License (MIT)
Change log
1.0.1
- Added method
getRenderedMarkup($templateName, $data)which allow to fetch the processed markup as raw html string. - Fixed some typos.
- Better readme, because you all read this right? :-D
1.0
- First version y'all!
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-02-15