将多个树枝变量连接在一个括号中

问题描述 投票:0回答:1

我想在一个括号中连接 3 个变量,就像 PHP 一样。

在 PHP 中:

getimagesize($path.$image)

我们可以用点符号连接变量。我怎样才能在树枝中重现这个?

{{ path.key }}
未按预期工作。

variables twig
1个回答
24
投票

使用波形符

~
连接字符串和/或变量。

~:将所有操作数转换为字符串并连接它们。 {{“你好”~名字~“!” }} 将返回(假设名称为“John”)Hello John!.

阅读文档中的相关内容

© www.soinside.com 2019 - 2024. All rights reserved.