由网友(惊鸿客)分享简介:有人知道如何在 twig 中连接字符串吗?我想做类似的事情:Anyone knows how to concatenate strings in twig? I want to do something like:{{ concat('http://', app.request.host) }}推荐答案这应该可以...
有人知道如何在 twig 中连接字符串吗?我想做类似的事情:
Anyone knows how to concatenate strings in twig? I want to do something like:
{{ concat('http://', app.request.host) }}
推荐答案
这应该可以正常工作:
{{ 'http://' ~ app.request.host }}
要在同一个标签中添加过滤器——比如trans"——使用
To add a filter - like 'trans' - in the same tag use
{{ ('http://' ~ app.request.host) | trans }}
正如 Adam Elsodaney 指出的,您也可以使用 字符串插值,这确实需要双引号字符串:
As Adam Elsodaney points out, you can also use string interpolation, this does require double quoted strings:
{{ "http://#{app.request.host}" }}
相关推荐
最新文章