Is it possible to use the path
function dynamically? With variables as parameters?
{{ path(nav.url, { nav.param_name : nav.param_value }) }}
Because if I try to use that code I am getting:
A hash key must be followed by a colon (:).
Unexpected token "punctuation" of value "."
("punctuation" expected with value ":")
I know by passing 'hardcoded' the param_name
will work... like this:
{{ path('nav.url', { 'id' : nav.param_value }) }}
However I need to pass the 3 value dynamically
The Twig book says you have to enclose expressions in parentheses to use them as keys, so maybe this will work:
{{ path(nav.url, { (nav.param_name) : nav.param_value }) }}
http://twig.sensiolabs.org/doc/templates.html#literals
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With