Is it possible to access Route parameter in twig template directly?

后端 未结 2 985
北海茫月
北海茫月 2020-12-29 01:45

A view element on my page depends on a route parameter and will render something if a route parameter is present. Is it possible to access Route parameter in twig template d

相关标签:
2条回答
  • 2020-12-29 02:12

    I am also having the same problem. To fix this issue I fist dumped the request object and go through the attributes. In attributes you can see all the available properties associated with the request which can be accessed by twig. For example

    app.request.attributes('_route'); //gives you route name
    app.request.attributes('slug'); //gives you path variable with in the controller with the name 'slug'
    
    0 讨论(0)
  • 2020-12-29 02:36

    You can achieve it like this:

    {{ app.request.get('name') }}
    
    0 讨论(0)
提交回复
热议问题