如何使用 silex slug 设置树枝路径()? [英] How to have twig path() with silex slug?
本文介绍了如何使用 silex slug 设置树枝路径()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在silex中我有类似的东西
In silex I have something like
$controllers->get('/{id}', 'Controllers\\Login::index')->bind('login');
当我尝试获取 path('login')
我得到异常
when in twig I try to get path('login')
I get exception
("Some mandatory parameters are missing ("id") to generate a URL for route "login"."). ?
我知道这是因为 {id} 而我必须将第二个参数传递给 path()
但它应该是什么样子的?
I know this is because of {id} and I have to pass a second parameter to path()
but how should it look like?
推荐答案
为了向 twig 路径传递参数,请使用以下语法:
In order to pass parameters to twig path, use the following syntax:
{{ path('login', {'id': 'your-id-here'}) }}
您可以在此处查看文档:
you can have a look at the documentation here:
您可以按照此处的说明传递多个参数:
You can pass several parameters as explained here:
这篇关于如何使用 silex slug 设置树枝路径()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文