简体   繁体   English

Symfony2:@Template批注和PHP模板

[英]Symfony2: @Template annotation and PHP templates

When I use Symfony, I name my views with the name of the corresponding action, so that I can use a @Template annotation without any parameters to render the view. 使用Symfony时,我用相应操作的名称来命名视图,以便可以使用不带任何参数的@Template注释来呈现视图。

/**
 * @Route("/{id}/show", name="entity_show")
 * @Template()
 */
public function showAction($id) {
}

Does this only work with Twig? 这仅适用于Twig吗? Is there a way to not having to specify the name of the view as a parameter for @Template when I use PHP views? 当我使用PHP视图时,是否有一种不必将视图名称指定为@Template的参数的@Template

除了Patt编写的内容之外,您还必须为注释的每次使用指定引擎:

@Template(engine="php")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM