Tom Tom - 1 year ago 135
Twig Question

Use twig variable in string

For the language selection I want to show the flag of the current active languages.

I get the language variable by:


Now I want to use the value in the string of the flag url.

<img src="{{ asset('flags/'+app.request.locale+'.png', 'img') }}" />

But what is the correct syntax for this?

Answer Source

You have to use ~ char instead of +.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download