来自the documentation ,没有如何使用 ESI 在模板内渲染模板的示例。可以这样做吗?
例如,我有一个模板 index.html.php
,我想使用 ESI 渲染 form.html.php
模板。如何做到这一点?
最佳答案
正如您提供的文档页面一样,您可以使用以下方式在另一个 Controller 中呈现一个 Controller :
{{ render_esi(controller('YourBundle:Default:news', { 'max': 5 })) }}
您还可以使用路由名称代替 Controller 引用:
{{ render_esi(url('latest_news', { 'max': 5 })) }}
但是,您需要设置 gateway cache让 ESI 发挥作用。
关于caching - Symfony2.2渲染ESI模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15269836/