{"id":20372861,"url":"https://github.com/sidmishraw/fmt","last_synced_at":"2025-12-06T03:04:05.538Z","repository":{"id":86400551,"uuid":"153569167","full_name":"sidmishraw/fmt","owner":"sidmishraw","description":"A simple parametric message formatter utility for Java","archived":false,"fork":false,"pushed_at":"2018-11-01T07:38:03.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-15T06:48:39.395Z","etag":null,"topics":["java-string-formatter","java8","string-formatter"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sidmishraw.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-18T05:40:23.000Z","updated_at":"2018-11-01T07:38:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"162359b3-c3ff-4e92-87e6-5ff0ebe1f022","html_url":"https://github.com/sidmishraw/fmt","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/sidmishraw%2Ffmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Ffmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Ffmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sidmishraw%2Ffmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sidmishraw","download_url":"https://codeload.github.com/sidmishraw/fmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241921836,"owners_count":20042763,"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":["java-string-formatter","java8","string-formatter"],"created_at":"2024-11-15T01:15:14.981Z","updated_at":"2025-12-06T03:04:05.484Z","avatar_url":"https://github.com/sidmishraw.png","language":"Java","readme":"# fmt\n\n```\nAuthor: Sidharth Mishra \u003csidmishraw@gmail.com\u003e\nVersion: 1.0.0\nJDK: 11\n```\n\n[![Build Status](https://travis-ci.com/sidmishraw/fmt.svg?branch=master)](https://travis-ci.com/sidmishraw/fmt)\n\n## About\n\n`fmt` is a simple fluent-API based string-template utility. It is used for providing parametric string formatting –– somewhat like Python's `str.format()`.\n\n```java\nvar template = \"{kong}{{kong}}!\";\nvar result = fmt.inTemplate(template).put(\"kong\", \"King\").put(\"king\", \"Kong\").eval(); // KingKong!\n```\n\nIn `fmt`, the template parameter is defined as `{template-parameter}`. Moreover, `fmt` makes keeps resolving all the template-parameters recursively till it can no longer resolve any more template parameters.\n\n## Approaches\n\nThe first approach would be to get a param-key-value pair out and start resolving the template recursively till all the template parameters have been resolved.\nFor example:\n\n```\ntemplate = \"{king}{{one}}{{{kong}}}\"\n\nparams = {\n    \"king\": \"kong\",\n    \"one\": \"two\",\n    \"kong\": \"king\"\n}\n\nstep 1: let one be picked (because I'm using a hashmap internally),\ntemplate1 = \"{king}{two}{{{kong}}}\"\n\nstep 2: let now king is selected\ntemplate2 = \"kong{two}{{{kong}}}\"\n\nstep 3: now kong is selected\ntemplate3 = \"kong{two}{{king}}\" \u003c\u003c it should stop here -- for one pass \u003e\u003e\n\nbut the final result should be:\n\"kong{two}king\",\n```\n\nto achieve the final result, `fmt` retries recursively trying to resolve the new template parameters. If it not able to resolve, it unwinds and returns the result.\n\n## Motivation\n\nI needed an utility that provided parameteric substitutions in Java like in Python. The existing MessageFormatter gives indexed based substitution and it is limiting for my use-case.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidmishraw%2Ffmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsidmishraw%2Ffmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsidmishraw%2Ffmt/lists"}