twig - Appending Raw HTML to variable -


consider following script:

{% set main="hello" %} {% set if=1 %} {% set id=123 %} {% set extra=456 %} {{ main~if?" <a href='ku?cf="~id~"&amp;ff="~extra~"'>xxx</a>"|raw }} 

my desire render following html:

hello <a href='ku?cf=123&amp;ff=456'>xxx</a> 

and if if zero, render following html:

hello 

how accomplished?

it appears raw must applied entire appended variable, , not portion of variable needs escaped.

{{ (main~(if?" <a href='ku?cf="~id~"&amp;ff="~extra~"'>xxx</a>"))|raw }} 

Comments