0

I have an array of twig get parrameters created with the following code:

$vars = get_defined_vars();

How can I pass it to twig tempalate, so that I can pass that as slugs variable? For example:

<a href="{{ path('route_name', {vars}}))">link</a>

The above of course does not work, as it's the wrong format. Is there a way to do this?

1 Answer 1

2

Given an associative array :

$vars = array( 'param1' => 'val1', 'param2' => 'val2' );
// then passed to the template as 'vars'

This works in Twig :

<a href="{{ path('route_name', vars) }}">link</a>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.