stringtemplate - Filter out empty strings in ST4 -


consider following example:

<["foo", "", "bar"]; separator=","> 

this gives result:

foo,,bar 

but need:

foo,bar 

is there way filter out empty string values before formating separator in st4?

(in real code values come template, has <if> condition , returns empty result undesired data model, , don't whant move condition out of template keep templates incapsulated/isolated.)

i've found workaround 2 auxilary things. creepy...

dropempty ::= ["": [], default: key]  separated(l, s, w=false) ::= "<if (dropempty.(first(l)))><if (w)><s><endif><first(l)><separated(rest(l), s, true)><else><if (rest(l))><separated(rest(l), s, w)><endif><endif>"  mytemplate() ::= << <separated(["", "foo", "", "bar", "", "", "goo", "", ""], ",")> >> 

this gives:

foo,bar,goo 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -