简体   繁体   English

是否可以连接大豆中的两个字符串(闭合模板)?

[英]Is it possible to concatenate two strings in soy (Closure Templates)?

With soy, I would like to concatenate two strings (hard-coded or variables) into one.使用大豆,我想将两个字符串(硬编码或变量)连接成一个。 My idea was to "parametrize" the first variable with the second:我的想法是用第二个变量“参数化”第一个变量:

{let $key: 'abc_$anothervariable' /}

This doesn't work.这不起作用。 I also tried using builtin join() function for lists:我还尝试对列表使用内置join()函数:

{let $key: join(['abc', $anothervariable], '') /}

But this approach doesn't work either - it even seems to have invalid syntax.但是这种方法也不起作用——它甚至似乎有无效的语法。 Is it even possible to do something like that in Closure Templates?甚至可以在 Closure Templates 中做类似的事情吗?

答案实际上很简单:

{let $key: 'abc_' + $anothervariable /}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM