【发布时间】:2019-02-14 03:26:10
【问题描述】:
我想要一个 html 元素,其中包含两个由 twig 变量定义的类。 我可以用一个 twig 变量来做到这一点,它们都单独工作。但是一旦我尝试将它们放在一起,只有第一堂课是有效的。 我在论坛上搜索过,但只找到了 html 中的 twig 类或两个类。 有了 Twig 我有:
<p class={{"type#{item.type1}"}}> Paragraph </p>
在 html 中应该是:
<p class="type1 type2"}}
当我尝试将两者组合如下时,它不起作用:
<p class={{"type#{item.type1} type#{item.type2}"}} > Paragraph </p>
我也尝试了~ 的其他 concat 方法,但没有成功。
How to concatenate strings in twig
我尝试添加&nbsp;而不是空格,正如这里解释的那样,也没有成功:
How to add space between variables in twig template?
【问题讨论】: