symfony2 - twig - 如何从树枝模板内部渲染树枝模板 [英] symfony2 - twig - how to render a twig template from inside a twig template

查看:33
本文介绍了symfony2 - twig - 如何从树枝模板内部渲染树枝模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示页面的 xxx.html.twig 文件,但是当我想用不同的数据刷新页面并用新数据更新它时,我有一个选择和一个提交按钮.问题是我不知道如何在控制器中调用一个动作,我从我的树枝传递参数并调用新数据,然后我再次使用新参数渲染相同的树枝模板.

I have a xxx.html.twig file which shows a page, but when I want to refresh the page with different data and just update it with new data, I have a select and a submit button for it. The thing is that I don't know how do I call an action in the controller which I pass parameters to from my twig and call for new data and then I render the same twig template again with new parameters.

我该怎么做?

推荐答案

Symfony 2.1:

{% render 'YourBundle:YourController:yourAction' with {'var': value} %}

Symfony 2.6+:

{{ render(controller('YourBundle:YourController:yourAction', {'var': value})) }}

当然,请阅读文档.

这篇关于symfony2 - twig - 如何从树枝模板内部渲染树枝模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆