{"id":15018106,"url":"https://github.com/typpo/nunjucks-phone-filter","last_synced_at":"2025-04-14T16:34:38.931Z","repository":{"id":65466736,"uuid":"64671976","full_name":"typpo/nunjucks-phone-filter","owner":"typpo","description":"phone number formatting filter for nunjucks templating engine","archived":false,"fork":false,"pushed_at":"2021-11-30T00:24:53.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T02:49:34.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typpo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-01T14:06:41.000Z","updated_at":"2023-04-29T17:50:49.000Z","dependencies_parsed_at":"2023-02-20T20:30:55.400Z","dependency_job_id":null,"html_url":"https://github.com/typpo/nunjucks-phone-filter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fnunjucks-phone-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fnunjucks-phone-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fnunjucks-phone-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typpo%2Fnunjucks-phone-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typpo","download_url":"https://codeload.github.com/typpo/nunjucks-phone-filter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248917093,"owners_count":21182927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T19:51:27.528Z","updated_at":"2025-04-14T16:34:38.906Z","avatar_url":"https://github.com/typpo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nunjucks-phone-filter\n[![npm](https://img.shields.io/npm/v/nunjucks-phone-filter)](https://www.npmjs.com/package/nunjucks-phone-filter)\n\nPhone number formatter for Nunjucks templating engine, based on Google's [libphonenumber](https://github.com/googlei18n/libphonenumber).\n\n```\nnpm install --save nunjucks-phone-filter\n```\n\n## Usage\n\nFirst get your nunjucks environment object.\n```js\n// Environment from normal nunjucks configuration with express...\nvar env = nunjucks.configure('views', {\n  express: app,\n  // ...\n});\n\n// or just create an environment object.\nvar env = new nunjucks.Environment();\n```\n\nUse `install()` to register a filter named `phone_number` with nunjucks:\n\n```js\nrequire('nunjucks-phone-filter').install(env);\n```\n\nOr, customize the filter name by using nunjucks `addFilter`:\n\n```js\nenv.addFilter('my_phone_formatter', require('nunjucks-phone-filter'));\n```\n\nThen use it in a nunjucks template:\n\n```\n\u003cp\u003e{{foo.phone | phone_number}}\u003c/p\u003e\n```\n\n## Optional formatting arguments\n\nThe `phone_number` filter takes two arguments, `country` and `format`. Both are strings.\n\nBy default, country is `US` and format is `NATIONAL`. Other valid formats are `INTERNATIONAL` and `E164` (see [E164 on wikipedia](https://en.wikipedia.org/wiki/E.164)).\n\nYou can pass arguments like so:\n\n```\n\u003cp\u003e{{foo.phone | phone_number('US', 'NATIONAL')}}\u003c/p\u003e\n```\n\n```\n{{ '9147727420' | phone_number('US', 'NATIONAL') }} ==\u003e (914) 772-7420\n{{ '9147727420' | phone_number('US', 'INTERNATIONAL') }} ==\u003e +1 914-772-7420\n{{ '9147727420' | phone_number('US', 'E164') }} ==\u003e (914) 772-7420\n\n{{ '2071234567' | phone_number('GB', 'NATIONAL') }} ==\u003e 020 7123 4567\n{{ '2071234567' | phone_number('GB', 'INTERNATIONAL') }} ==\u003e +44 20 7123 4567\n{{ '2071234567' | phone_number('GB', 'E164') }} ==\u003e 020 7123 4567\n```\n\n## Default arguments\n\nYou can override the default country and format by calling `setDefaultCountry` and `setDefaultFormat`.\n\nFor example:\n```\nconst phoneFilter = require('nunjucks-phone-filter');\n\nphoneFilter.setDefaultCountry('GB');\nphoneFilter.setDefaultFormat('INTERNATIONAL');\n\nphoneFilter.install(env);\n```\n\nBecause defaults have been modified, you no longer have to pass arguments to `phone_number`:\n```\n{{ '2071234567' | phone_number }} ==\u003e +44 20 7123 4567\n```\n\n## License (MIT)\n\nCopyright (C) 2016 by Ian Webster (ianww.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyppo%2Fnunjucks-phone-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyppo%2Fnunjucks-phone-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyppo%2Fnunjucks-phone-filter/lists"}