Skip to content

Instantly share code, notes, and snippets.

@thomasthesecond
Last active February 22, 2022 04:07
Show Gist options
  • Save thomasthesecond/1a5e28e14a25e31e8d33 to your computer and use it in GitHub Desktop.
Save thomasthesecond/1a5e28e14a25e31e8d33 to your computer and use it in GitHub Desktop.
Twig filter for formatting telephone numbers for anchors
+1-{{ phoneNumber|trim|replace({'(': '', ')': '', ' ': '-', '.': '-'}) }}
@davidmintz
Copy link

davidmintz commented Feb 22, 2022

Nicely done -- but was looking for one to go in the opposite direction, and I'm surprised not to find one. Maybe it's just too easy to write your own custom twig filter, especially in Symfony apps. So, https://gist.github.com/davidmintz/8b532e1a1387bdf2c8b8769c997fdd9b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment