bobthecow / mustache-bundle
Symfony Mustache.php 扩展包
v1.2.0
2014-07-10 12:09 UTC
Requires
- php: >=5.3.2
- mustache/mustache: ~2.5
This package is auto-updated.
Last update: 2024-09-20 10:19:08 UTC
README
这是 Mustache 模板渲染的 Symfony 实现。这将把 Mustache 作为渲染器添加到 Symfony 中。
- 安装
Composer
只需使用 composer 运行以下命令
composer.phar require bobthecow/mustache-bundle
从 Packagist 查找所需的版本约束。添加后运行
composer.phar update
AppKernel
以实际下载和使用此扩展包。同时,将以下行添加到您的 AppKernel.php
new Bobthecow\Bundle\MustacheBundle\BobthecowMustacheBundle()
config.yml
将渲染器添加到您的 config.yml
framework:
templating:
engines: ['twig', 'mustache']
- 使用方法
就像使用 twig 一样。只需将您的 mustache 文件放在 Resources\views 文件夹中,并使用 .mustache
作为扩展名。例如。
// Render Mustache template and return response
return $this->render('AcmeDemoBundle:Hello:index.html.mustache');
或者通过 Template() 注解传递模板
/**
* @Template("AcmeDemoBundle:Hello:index.html.mustache")
*/
public function indexAction()
{
return array();
}