Q:

String escaping with twig?

QUESTION:
How do you append the following twig variable at the end of the first parameter of the anchor function?
{{ anchor('welcome/play/', 'Play', {'class': 'btn btn-primary'})|raw }}

I have tried variations of: 'welcome/play/{{t.CompetitionID}}' etc which doesnt work.

A:

You could use ~ to concatenate strings http://twig.sensiolabs.org/doc/templates.html#expressions :

~: Converts all operands into strings and concatenates them. {{ "Hello
  " ~ name ~ "!" }} would return (assuming name is 'John') Hello John!.

Thus:
{{ anchor('welcome/play/' ~ t.competitionID, 'Play', {'class': 'btn btn-primary'})|raw }}

