Reputation: 23613
I have a link template:
link.twig:
<a class="something" href="{{ url }}">{{ text }}</a>
And im calling the template and passing it values:
page.twig:
{% include "link.twig" with {'url': 'www.google.com', 'text': 'Search engine} %}
This was working but now I need to have url and text as part of a link object:
<a class="something" href="{{ link.url }}">{{ link.text }}</a>
How can I pass values from page.twig? The following gives me a white screen of death:
{% include "link.twig" with {link.url: 'www.google.com', link.text: 'Search engine} %}
Upvotes: 1
Views: 428
Reputation: 1301
You can directly include an array :
{% include "link.twig" with {link : { url: 'www.google.com', text: 'Search engine'} } %}
Upvotes: 1