{"id":19994195,"url":"https://github.com/b4dnewz/string-template","last_synced_at":"2025-03-01T22:50:23.660Z","repository":{"id":36129728,"uuid":"221702847","full_name":"b4dnewz/string-template","owner":"b4dnewz","description":"A utility to format strings with many options","archived":false,"fork":false,"pushed_at":"2023-01-05T00:51:22.000Z","size":659,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T17:15:33.604Z","etag":null,"topics":["replacement","string","string-formatter","string-manipulation","string-template","string-utility","template","utility"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b4dnewz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-14T13:22:08.000Z","updated_at":"2019-11-28T19:17:47.000Z","dependencies_parsed_at":"2023-01-16T23:31:04.127Z","dependency_job_id":null,"html_url":"https://github.com/b4dnewz/string-template","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/b4dnewz%2Fstring-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fstring-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fstring-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b4dnewz%2Fstring-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b4dnewz","download_url":"https://codeload.github.com/b4dnewz/string-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241435151,"owners_count":19962401,"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":["replacement","string","string-formatter","string-manipulation","string-template","string-utility","template","utility"],"created_at":"2024-11-13T04:54:18.437Z","updated_at":"2025-03-01T22:50:23.626Z","avatar_url":"https://github.com/b4dnewz.png","language":"TypeScript","readme":"# string-template\n\n\u003e A utility to format strings with many options\n\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\n## Getting started\n\nDownload it using your favourite package manager.\n\n```\nnpm i @b4dnewz/string-template\n```\n\nThen import it in your code and __have fun__ formatting strings.\n\n```js\nimport template from \"@b4dnewz/string-template\";\n\nconst str = `\n    That's an awfully hot {item},\n    did {person} kill himself?\n    Probably {answer}.\n`;\n\ntemplate(str, {\n    item: \"coffee pot\",\n    person: \"Jeffrey Epstein\",\n    answer: \"not\"\n});\n```\n\nBy default the function will fail if unknown properties are found, but can be disabled using options.\n\n## Using custom pattern\n\nThe string template function will use this pattern `{%s}`, for finding variables in the string, where __%s__ will be replaced with the built-in word match pattern which is not customizable.\n\nIf you want to use a different template pattern you can add the __pattern__ option as third parameter.\n\n```js\nconst str = `Using a \u003c:adjective:\u003e pattern`;\n\nconst out = template(str, {\n    adjective: \"different\"\n}, {\n    pattern: \"\u003c:%s:\u003e\"\n});\n\nconsole.log(out);\n```\n\n## Options\n\n#### pattern\n\nType: `string`\n\nThe string template pattern to use for finding replacements, it __must use__ the string replacer `%s` to know where to put the word pattern.\n\n```js\ntemplate(input, replacements, {\n    pattern: \":%s:\"\n});\n```\n\n#### ignoreErrors\n\nType: `boolean`\n\nWhen `true` unknown properties in the string will not raise an error and will simply ignored.\n\n```js\ntemplate(input, replacements, {\n    ignoreErrors: true\n});\n```\n\n---\n\n## License\n\nThis package is released under [MIT License](./LICENSE) © [Filippo Conti](https://b4dnewz.github.io/)\n\n\n[npm-image]: https://badge.fury.io/js/%40b4dnewz%2Fstring-template.svg\n[npm-url]: https://npmjs.org/package/@b4dnewz/string-template\n[travis-image]: https://travis-ci.org/b4dnewz/string-template.svg?branch=master\n[travis-url]: https://travis-ci.org/b4dnewz/string-template\n[coveralls-image]: https://coveralls.io/repos/b4dnewz/string-template/badge.svg\n[coveralls-url]: https://coveralls.io/r/b4dnewz/string-template","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4dnewz%2Fstring-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb4dnewz%2Fstring-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb4dnewz%2Fstring-template/lists"}