尝试将字符串数组连接起来,使它们在下一行出现,使用FTL模板。

huangapple go评论82阅读模式
英文:

Trying to join array of strings, such that they occur in next line using FTL template

问题

以下是要翻译的内容:

这是一个字符串数组,myArray = ["green", "blue", "red"],我想在 HTML 页面上每行显示一个值:
"green"
"blue"
"red"

我尝试了以下方式但没有成功:

${myArray?join("\r\n")}
英文:

Here is array of strings, myArray = ["green","blue","red"], I want to display each value in next line on html page
"green"
"blue"
"red"

I tried something like below but didnt work.
<td>${myArray?join("\r\n")}</td>

答案1

得分: 0

To show each element on a new line using FTL template you can use the <#list> and
tag for new line. Here is my code:

<#list myArray as item>
${item}
</#list>

英文:

To show each element on a new line using FTL template you can use the <#list> and <br> tag for new line. Here is my code:

&lt;#list myArray as item&gt;
  ${item}&lt;br&gt;
&lt;/#list&gt;

huangapple
  • 本文由 发表于 2023年5月17日 08:58:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76267936.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定