Created
October 28, 2017 20:50
-
-
Save veb/72b83fd7e434bc02e4ba102aa9a77f41 to your computer and use it in GitHub Desktop.
Phone twig filter for twigjs/express
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... app.js stuff | |
Twig.extendFilter("phone", function(value) { | |
var value = "" + value; | |
return value.replace(/(\d{1})(\d{4})(\d{3})/, "0$1-$2-$3"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mainly for NZ phone numbers like: 34653245 -> 03-465-3245