Romainpetit
Romainpetit

Reputation: 906

Twig include : use translation in the passed argument

This works fine

{% include 'site/snippet.html.twig'
    with {'description': 'Some text'}
%}

But how to get this to work? Using a translation as argument

{% include 'site/snippet.html.twig'
    with {'description': '{{ 'solutions.description' | trans }}'}
%}

The snippet.html content is:

<p>
    {{ description }}
</p>

And calling the translation {{ 'solutions.description' | trans }} alone shows the content as expected.

What syntax would it be?

Upvotes: 1

Views: 911

Answers (1)

insertusernamehere
insertusernamehere

Reputation: 23580

You don't need to wrap the string in an extra set of {{ }}. Actually it should work like:

with {'description': 'solutions.description'|trans}

Upvotes: 7

Related Questions