Symfony Twig {{render}} handling passed arguments

邮差的信 提交于 2019-12-24 16:34:04

问题


Over a template I do a render method:

{{ render(controller('AppBundle:Widgets:myCapsWidget'),{'somestring':someString})  }}

Over the controller I have the following method:

public function myCapsWidgetAction($somestring)
{
  return new Response(strtoupper($somestring));
}

I also looked over theese links:

  • symfony twig render controller argument array
  • https://knpuniversity.com/screencast/symfony2-ep3/render-controller

But still cannot find any light to my path.


回答1:


If I read the first link you gave us, you should use:

{{ render(controller('AppBundle:Widgets:myCapsWidget',{'somestring':someString}))  }}


来源:https://stackoverflow.com/questions/47094755/symfony-twig-render-handling-passed-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!