简体   繁体   English

Symfony中不同的树枝和模板位置

[英]Different Twig and Templates Location in Symfony

In Symfony by default, templates can live in two different locations: 默认情况下,在Symfony中,模板可以位于两个不同的位置:

  1. app/Resources/views/ 应用程序/资源/视图/
  2. path/to/bundle/Resources/views/ 路径/到/包/资源/视图/

How can you render Templates also from other Locations? 您如何也可以从其他位置渲染模板?

  1. For Example I want my Application Themes be in the web/Themes folder: 例如,我希望我的应用程序主题位于web / Themes文件夹中:

web/Layouts/layout.twig.html web/Layouts/layout.less ... web / Layouts / layout.twig.html web / Layouts / layout.less ...

  1. Or just store Templates in a folder in base path: 或仅将模板存储在基本路径的文件夹中:

web/ app/ Themes/ ... 网络/应用程序/主题/ ...

While you can do that as decribed in define custom filesystem path for twig templates , I would not advertise to put them in the web directory. 虽然您可以按照定义树枝模板的自定义文件系统路径中所述的方法进行操作 ,但我不会做广告来将它们放在web目录中。 Things in the web directory are publicy available. web目录中的内容是公开可用的。 Raw templates, before parsing should not be publicy available. 解析前的原始模板不应公开可用。

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

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