Search code examples
freemarker

Return list as concatenated string


I have input data as test="122 drshshs 000 dkkdkdk 200"

<#list test?split(" ") as curr>
${curr}
</#list>

In o/p i m getting output as :

122
drshshs
000
dkkdkdk
200

Is there any freemarker short hand function that can directly string give o/p as below instead of looping and adding each string to a variable:

122,drshshs,000,dkkdkdk,200

Solution

  • You can split the string and then join it with a comma:

    ${test?split(" ")?join(",")}