Fabian
Fabian

Reputation: 1836

TWIG: is it possible to have two filters or variable in variable?

I want to do following

{% set checkicon = '<a id="{{ participant.id }}">' %}

<td>{{ checkicon | raw }}</td>

It doesnt word because twig variable in twig variable-definition is not possible. i heard about doing somthing like this

<td>{{ checkicon | replace({ '{{ participant.id }}': participant.id }) }}</td>

but now i have the problem that i want to add the raw-filter too. is it possible to add two filters to a twig variable? didnt found anything about that on net.

ty in advance!

Upvotes: 0

Views: 144

Answers (1)

Adam Elsodaney
Adam Elsodaney

Reputation: 7808

Try this. The ~ token is a concatenation for strings.

{% set checkicon = '<a id="' ~ participant.id ~ '">' %}

Upvotes: 2

Related Questions