I'm using Twig with Slim and their Twig-View view layer. This view layer has a function for creating URLs, which from the documentation looks like this:
{{ path_for('profile', { 'name': 'josh' }) }}
This works fine, but I have problems when the parameters are built with variables from dynamic data. For example this expression:
{{ path_for('profile', { 'name': '{{ PERSON.name }}' }) }}
Is simply evaluated as {{ PERSON.name }}
. Twig does not parse the content of {{ PERSON.name }}
, it just returns this as the value, so my URL looks something like /path/to/profile/{{ PERSON.name}}
. If I move the expression outside my function call it is evaluated correctly.
I have looked at the attribute
function, but can not figure out how to use this is my situation, as it seem more suited for calling functions dynamically on objects.