Display a variable in a path()

Viewed 50

What I have : a variable called url that contains a string and that is sent to the view by controller.

What I want : I must have the following url at the end: https://example.org/url

What I tried : <a href="{{ path('{{ url }}') }}">Go to URL</a> and some stuff.

Of course, it doesn't work.
Can someone can help?

1 Answers
<a href="{{ path(url) }}">Go to URL</a>

If you put something inside quotes when you are inside twig delimiters it will be considered as a string, here you want to evaluate the variable url, so you simply have to put the name of the said variable and it will be evaluated this way.

Related