laastiviews

一个与HTTP消息兼容的模板引擎抽象。

v0.2.3 2017-05-03 20:44 UTC

This package is auto-updated.

Last update: 2024-08-29 04:25:23 UTC


README

一个与HTTP消息兼容的模板引擎抽象。提供可以附加到HTTP消息的Response上的TemplateStream。

目前只支持PHP和Mustache (bobthecow/mustache.php)模板,欢迎通过PR添加更多引擎。

安装

composer require laasti/views

用法

$renderer = new \Laasti\Views\TemplateRenderer;
//You can add many engines to support multiple template types
$renderer->addEngine(new \Laasti\Views\Engines\PlainPhp([/*View directory*/]));
//You can set global data to pass on to all template
$renderer->setData('sitename', 'Hello world!');
//Or you can pass data only to one template
$template = new \Laasti\Views\Template("template-name.php", new \Laasti\Views\Data\ArrayData(['title' => 'Hello world!']));
//attackStream will create a TemplateStream and attach it to the response's body
$response = $renderer->attachStream($response, $template);

//The title and sitename will be available as $title and $sitename in the template

贡献

  1. 分叉它!
  2. 创建您的功能分支: git checkout -b my-new-feature
  3. 提交您的更改: git commit -am '添加一些功能'
  4. 推送到分支: git push origin my-new-feature
  5. 提交拉取请求 :D

历史

查看GitHub的发行版或标签

致谢

作者:Sonia Marquette (@nebulousGirl)

许可

在MIT许可证下发布。查看LICENSE.txt文件。