{"id":32322338,"url":"https://github.com/igor-palaguta/swiftyformat","last_synced_at":"2026-02-20T23:02:12.073Z","repository":{"id":56922324,"uuid":"78890077","full_name":"Igor-Palaguta/SwiftyFormat","owner":"Igor-Palaguta","description":"String and NSAttributedString with format","archived":false,"fork":false,"pushed_at":"2020-04-15T13:55:56.000Z","size":28,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-23T12:40:48.019Z","etag":null,"topics":["attributedstring","format","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/Igor-Palaguta.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":"2017-01-13T21:59:24.000Z","updated_at":"2020-04-15T13:55:59.000Z","dependencies_parsed_at":"2022-08-21T04:50:22.945Z","dependency_job_id":null,"html_url":"https://github.com/Igor-Palaguta/SwiftyFormat","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Igor-Palaguta/SwiftyFormat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-Palaguta%2FSwiftyFormat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-Palaguta%2FSwiftyFormat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-Palaguta%2FSwiftyFormat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-Palaguta%2FSwiftyFormat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Igor-Palaguta","download_url":"https://codeload.github.com/Igor-Palaguta/SwiftyFormat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Igor-Palaguta%2FSwiftyFormat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29667119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T19:49:36.704Z","status":"ssl_error","status_checked_at":"2026-02-20T19:44:05.372Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["attributedstring","format","swift"],"created_at":"2025-10-23T12:33:34.168Z","updated_at":"2026-02-20T23:02:12.061Z","avatar_url":"https://github.com/Igor-Palaguta.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/Igor-Palaguta/SwiftyFormat.svg?branch=master)](https://travis-ci.org/Igor-Palaguta/SwiftyFormat)\n\n# SwiftyFormat\n\n\nSwiftyFormat - string formatter library with simple format syntax #{{key|default value|prefix|suffix}}.\n\n1. *key* (required) is used for identifying parameter inside mapping\n2. *default value* (optional) this value is used when mapping returns nil for key\n3. *prefix* (optional) is added before value. Not added for default value\n4. *suffix* (optional) is added after value. Not added for default value\n\n## Example\n\n```\nlet format = \"#{{user}} mentioned you in a comment. #{{comment}}\"\nlet result = NSAttributedString(format: format, mapping: [\"user\": \"Jack\", \"comment\": \"How are you Jill?\"])\n```\n\n\nClosure can be passed instead of dictionary. It is useful, when format can be changed, and not all parameters required for every format.\n\n```\nlet result = NSAttributedString(format: someFormat) { key in\n   switch key {\n   case \"name\":\n      return NSAttributedString(string: \"Jack\", attributes: nameAttributes)\n   case \"cookies\":\n      return cookies\n   default:\n      return nil\n   }\n}\n```\n\n\nYou can also specify default value, prefix and suffix\n\n```\nlet format = #\"#{{user}} mentioned you in a comment#{{comment|| \"|\"}}\"#\nlet result1 = NSAttributedString(format: format, mapping: [:])\n//result1 == Your friend mentioned you in a comment\nlet result2 = NSAttributedString(format: format, mapping: [\"name\": \"Jack\", comment: \"How are you?\"])\n//result2 == Jack mentioned you in a comment \"How are you?\"\n```\n\n\nSame format syntax can be used for String\n\n```\nlet format = \"#{{user}} mentioned you in a comment. #{{comment}}\"\nlet result = String(format: format, mapping: [\"user\": \"Jack\", \"comment\": \"How are you Jill?\"])\n```\n\n## Requirements\n\nSwiftyFormat supports Swift 5\n\n## Installation\n\nCocoapods:\n```\npod \"SwiftyFormat\", :git =\u003e 'https://github.com/Igor-Palaguta/SwiftyFormat.git'\n```\n`\n\nCarthage:\n```\ngithub \"Igor-Palaguta/SwiftyFormat\"\n```\n\nSPM:\n```\n.package(url: \"https://github.com/Igor-Palaguta/SwiftyFormat.git\", from: \"0.3.0\")\n```\n\n## Author\n\nIgor Palaguta, igor.palaguta@gmail.com\n\n## License\n\nSwiftyFormat is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-palaguta%2Fswiftyformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figor-palaguta%2Fswiftyformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figor-palaguta%2Fswiftyformat/lists"}