Skip to content

Instantly share code, notes, and snippets.

@veb
Created October 28, 2017 20:50
Show Gist options
  • Save veb/72b83fd7e434bc02e4ba102aa9a77f41 to your computer and use it in GitHub Desktop.
Save veb/72b83fd7e434bc02e4ba102aa9a77f41 to your computer and use it in GitHub Desktop.
Phone twig filter for twigjs/express
// ... app.js stuff
Twig.extendFilter("phone", function(value) {
var value = "" + value;
return value.replace(/(\d{1})(\d{4})(\d{3})/, "0$1-$2-$3");
});
@veb
Copy link
Author

veb commented Oct 28, 2017

Mainly for NZ phone numbers like: 34653245 -> 03-465-3245

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