What would be the most concise/readable way in a velocity template to join multiple fields with a separator while leaving out empty or null Strings without adding excess separators?
As an example we have a tooltip or appointments that goes like:
Appointment ($number) [with $employee] [-] [$remarks] [-] [$roomToVisit]
Where I used brackets to indicate optional data. When filled in it would normally show as
Appointment (3) with John - serve Java coffee - ballroom
When $remarks is empty but $roomToVisit is not, this becomes:
Appointment (3) with John - ballroom
When instead $roomToVisit is empty we get:
Appointment (3) with John - serve Java coffee
When both are empty:
Appointment (3) with John
Bonus: also make the field prefix optional. When only $employee is empty we should get:
Appointment (3) serve Java coffee - ballroom
Ideally I would like the velocity template to look very similar to the first code box. If this is not possible, how would you achieve this with a minimum of distracting code tags?
Similar ideas (velocity example may help but is much more verbose):