Home / Documentation / Address Autocomplete / Before and After attributes

Before and After attributes

Address Autocomplete placeholders now support “before” and “after” attributes. Example:

{subpremise:long_name after="/"}

This allows for extra content to be placed either before or after a placeholder’s value but only if it exists.

Say you wanted to show this result in a field: 123 Sunshine St, Fort Collins, CO 80525. You could do the following:

{address1:long_name}, {locality:long_name}, {administrative_area_level_1:short_name}{postal_code:long_name}

If for some reason Google did not return a value for the city (Fort Collins), this could return an ugly formatted result: 123 Sunshine St, , CO 80525. This is not ideal.

Instead, you can use the “after” attribute:

{address1:long_name after=", "}{locality:long_name after=", "}{administrative_area_level_1:short_name after=" "}{postal_code:long_name}

Without the city, the end result would still be nicely displayed: 123 Sunshine St, CO 80525.