It’s common to need to output a single phone number formatted in a different way than it’s entered by the editor. Plus if the editor has to enter multiple phone numbers in multiple fields, you cannot assume they would enter them in a consistent formatting. So here’s a Perch template filter to make your life a little easier.
The template filter uses Google’s library libphonenumber for formatting and validating phone numbers.
You specify the country of the phone number with the
country attribute. You can optionally define a default country and omit the
output attribute specfies how you want to format the phone number. You can check the available options in the documentation.
<a href="<perch:content id="phone_number" filter="phone" country="gb" output="tel_link">" > <perch:content id="phone_number" filter="phone" country="gb" output="international"> </a>