I'm using MessageFormat to format some addresses with a template like this:
"{0}\n{1}\n{2}\n{3}, {4} {5}"
where
- 0 = street 1
- 1 = street 2
- 2 = street 3
- 3 = city
- 4 = state
- 5 = zip
Most of these fields are optional when captured. How do I avoid having an empty line when for instance, there is not street 3? I could use a template like this "{0}{1}{2}{3}{4}{5}" and then substitute either "street 3\n" or "" accordingly, but then the template doesn't provide much benefit toward formatting.
Is there a way to include conditionals in the format string? Or is there another, preferably lightweight, templating tool available that supports conditional formatting?