Boolean - Output displays extra commas

I'm looking for a solution that allows me to have multiple boolean selections and what ever is in a true state will output this into a comma delimited output. Anything that is set to false shows doesn't included the comma.

#set($1STRING='')
#if ($param1STRING=="true")
  #set($1STRING='1STRING')
#elseif ($param1STRING=="false")
  #set($1STRING='')
#set($2STRING='')
#if ($param1STRING=="true")
  #set($2STRING='2STRING')
#elseif ($param2STRING=="false")
  #set($2STRING='')
#end  
#set($3STRING='')
#if ($param3STRING=="true")
  #set($3STRING='1STRING')
#elseif ($param1STRING=="false")
  #set($1STRING='')
||$1STRING, $2STRING, $3STRING |

This is the output that I would like to have:

1STRING,2STRING,3STRING

This is an output that I can do not want. When a boolean option is not selected. It display an unnecessary comman.

1STRING,,3STRING

 

1 answer

I don't know what you need this for, but you could just add the comma to the strings itself (if they're not empty) instead of outputting "$1STRING,". This leads to the fact, that no comma will be displayed, if $2STRING is empty.

Cheers,
Kirstin

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

374 views 20 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you