How to Format a Phone Number in HubSpot CMS HubL


How to Format a Phone Number in HubSpot CMS HubL

I was recently working on a custom HubSpot quote theme and needed to format the phone number. By default, the number was displayed as a long string of numbers without any parenthesis or number groupings. The code below uses a HubL to display a subset of the full string in the chunks you need it to appear.

<a href="tel:{{ quote.hs_sender_phone }}">
+{{ quote.hs_sender_phone[:1] }}({{ quote.hs_sender_phone[1:4] }}) {{ quote.hs_sender_phone[4:7] }}-{{ quote.hs_sender_phone[7:11] }}
</a>

 


Written by: Jake Lett
Jake Lett is a B2B marketing consultant with over 15 years of experience in the digital marketing industry. He specializes in SEO, HubSpot, and PPC campaign management. Jake has a proven track record of helping businesses increase their online visibility and drive more traffic, leads and sales. He is a Certified Google Ads Specialist and a Certified HubSpot Developer.

Related posts

Tags:

Want to Get Email Updates of New Articles?

Join My Email Newsletter