americanreading/view-twig 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

americanreading/view-twig

最新稳定版本:v2.1.0

Composer 安装命令:

composer require americanreading/view-twig

包简介

Twig Implementation of Views

README 文档

README

Twig-backed implementation of View and ViewFactory.

To use, include with Composer:

{
  "require": {
    "americanreading/view-twig": "^1",
    "twig/twig": "^2"
  }
}

Configure a Twig_Environment and pass this to the TwigView constructor along with the root path to the view templates.

$templateRoot = '/path/to/twig/template/files';
$loader = new \Twig_Loader_Filesystem($templateRoot);
$conf = [
    'debug' => true,
    'cache' => false,
    'autoescape' => false
];
$twig = new \Twig_Environment($loader, $conf);
// Provide a context array to use as a default for all views.
$defaultContext = [
  'cat' => 'Molly'
];
// Create the factory.
$factory = new TwigViewFactory($twig, $templateRoot, $defaultContext);

Use the factory to provide View instances for a given template file:

$view = $factory->getView('my-template.twig.html');

Render the view to a string, merging in a context array.

$html = $view->render(['dog' => 'Bear']);

统计信息

  • 总下载量: 8.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-05-22