{"id":22235304,"url":"https://github.com/williamthome/interpolate","last_synced_at":"2025-10-04T18:06:41.335Z","repository":{"id":197642862,"uuid":"699037391","full_name":"williamthome/interpolate","owner":"williamthome","description":"An Erlang library to interpolate strings.","archived":false,"fork":false,"pushed_at":"2023-10-02T03:13:05.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T08:43:21.386Z","etag":null,"topics":["erlang","erlang-library","interpolation","string","stringinterpolation"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=williamthome.erlang-interpolate","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamthome.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":["williamthome"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://www.buymeacoffee.com/williamthome"]}},"created_at":"2023-10-01T18:25:38.000Z","updated_at":"2023-10-15T02:49:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd8d27cc-a71c-4620-ba83-aba3ec407bb9","html_url":"https://github.com/williamthome/interpolate","commit_stats":null,"previous_names":["williamthome/interpolate"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamthome%2Finterpolate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamthome%2Finterpolate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamthome%2Finterpolate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamthome%2Finterpolate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamthome","download_url":"https://codeload.github.com/williamthome/interpolate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245433161,"owners_count":20614447,"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":["erlang","erlang-library","interpolation","string","stringinterpolation"],"created_at":"2024-12-03T02:12:45.936Z","updated_at":"2025-10-04T18:06:36.259Z","avatar_url":"https://github.com/williamthome.png","language":"Erlang","funding_links":["https://github.com/sponsors/williamthome","https://www.buymeacoffee.com/williamthome"],"categories":[],"sub_categories":[],"readme":"# interpolate\n\nAn Erlang library to interpolate strings.\n\n## Usage\n\nUse the `interpolate:string/1` function or add the header `-include_lib(\"interpolate/include/interpolate.hrl\").` to your module and the `?f` macro will be available to format your string.\n\n## Example\n\nIn an Erlang module:\n\n```erlang\nmodule(math).\n\n-export([sum/2]).\n\n-include_lib(\"interpolate/include/interpolate.hrl\").\n\nsum(X, Y) -\u003e\n    ?f(\"The sum of ~p[X] and ~p[Y] is ~p[X+Y]\").\n```\n\nThe result of the function will be a UTF-8 binary:\n\n```erlang\n1\u003e math:sum(1,2).\n\u003c\u003c\"The sum of 1 and 2 is 3\"\u003e\u003e\n```\n\n## How it works\n\nThis lib uses a `parse_transform` to expand the string to the `io_lib:format/2` function. The string should be written thinking in the `io_lib:format/2` syntax, but the arguments of the [control sequences](https://www.erlang.org/doc/man/io#format-2) must be written next to them inside closed brackets, as a list. All control sequences are auto-prefixed with the modifier `t` (Unicode translator) For example:\n\n```\nFoo = \"😊\",\n\u003c\u003c\"😊\"/utf8\u003e\u003e = ?f(\"~s[Foo]\").\n```\n\nThe `?f(\"~s[Foo]\")` is compiled to `interpolate:string(\"~s[Foo]\")` and expanded to\n```erlang\niolist_to_binary(io_lib:format(\u003c\u003c\"~ts\"/utf8\u003e\u003e, [Foo])).\n```\n\nSee more examples in the `interpolate_test.erl` under the `test` folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamthome%2Finterpolate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamthome%2Finterpolate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamthome%2Finterpolate/lists"}