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

后端 未结 2 1011
北海茫月
北海茫月 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条回答
  •  猫巷女王i
    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'
    

提交回复
热议问题