Get current URI in Twig template

非 Y 不嫁゛ 提交于 2019-12-22 05:21:17

问题


Does anybody know how to get the current URI in a Twig template?

I’ve read through the documentation and I’m unable to find the Twig function to do this.


回答1:


{{ app.request.uri }}

If you want to read it into a view variable:

{% set uri = app.request.uri %}

The app global view variable contains all sorts of useful shortcuts, such as app.session and app.security.token.user, that reference the services you might use in a controller.



来源:https://stackoverflow.com/questions/7881233/get-current-uri-in-twig-template

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