[英]String escaping with twig?
QUESTION: 题:
How do you append the following twig variable at the end of the first parameter of the anchor function? 如何在锚函数的第一个参数的末尾附加以下twig变量?
{{ anchor('welcome/play/', 'Play', {'class': 'btn btn-primary'})|raw }}
I have tried variations of: 'welcome/play/{{t.CompetitionID}}' etc which doesnt work. 我尝试了以下几种变体:'welcome / play / {{t.CompetitionID}}',但这种方法不起作用。
You could use ~
to concatenate strings http://twig.sensiolabs.org/doc/templates.html#expressions : 您可以使用
~
连接字符串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!.
}}会返回(假设名称为“ John”),您好约翰!
Thus: 从而:
{{ anchor('welcome/play/' ~ t.competitionID, 'Play', {'class': 'btn btn-primary'})|raw }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.