在 Twig 路径中添加多个参数 [英] Add more than one parameter in Twig path
本文介绍了在 Twig 路径中添加多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Twig路径中添加多个参数?
假设您有这条路线:
How to add more than one parameter in Twig path?
Say you have this route :
article_show:
pattern: /article/{slug}
defaults: { _controller: AcmeArticleBundle:Article:show }
您可以在树枝模板中执行此操作:
You can do this in your twig template :
{{ path('article_show', { 'slug': article.slug }) }}
但是如果你的路由文件中有这个怎么办:
but what if you have this in your routing file:
_files_manage:
pattern: /files/management/project={idproject}&user={iduser}
defaults: { _controller: AcmeTestBundle:File:manage }
他们的文档中似乎没有涵盖这一点.
It looks like they didn't cover this in their documentation.
推荐答案
你可以传递任意数量的参数,用逗号分隔:
You can pass as many arguments as you want, separating them by commas:
{{ path('_files_manage', {project: project.id, user: user.id}) }}
这篇关于在 Twig 路径中添加多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文