Formatting multi line addresses with commas

I want this…

The Beach House,
Seaview Road,
Brighton,
BN1 1AA

and not this…

The Beach House,
Seaview Road,
,
Brighton,
,
BN1 1AA

I can start off with this

<td>{{property}}
{{street}}
{{locality}}
{{post_town}}
{{county}}
{{postcode}}</td>

then add commas and line breaks

<td>{{property}},<br>
{{street}},<br>
{{locality}},<br>
{{post_town}},<br>
{{county}},<br>
{{postcode}}</td>

or the same thing within one binding

<td>{{property + ",<br>" + street + ",<br>" + locality + ",<br>" + post_town + ",<br>" + county + ",<br>" + postcode}}</td>

But what about those properties without ‘property’ or ‘locality’ or ‘county’ as above? I don’t want to be left with gaps. Logic tells me to put

IF street exists THEN "street,<br>" ELSE ""

Do I really need to do this for every line? Is there an easy Wappler way to do this?

Hello, wrap them in <p> or <span> and use dmx-show attribute like:

<p dmx-show="your_binding">{{your_binding}},</p>

or you can add commas via CSS using ::before or ::after pseudo classes.

3 Likes