{"id":22339158,"url":"https://github.com/eptwalabha/mustache","last_synced_at":"2025-03-26T08:44:40.004Z","repository":{"id":152789279,"uuid":"547454126","full_name":"Eptwalabha/mustache","owner":"Eptwalabha","description":"render Mustache template with Erlang","archived":false,"fork":false,"pushed_at":"2024-03-05T10:14:07.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-31T10:16:37.733Z","etag":null,"topics":["erlang","mustache","template"],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/Eptwalabha.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}},"created_at":"2022-10-07T18:01:00.000Z","updated_at":"2022-10-09T18:29:17.000Z","dependencies_parsed_at":"2023-05-22T14:15:32.043Z","dependency_job_id":null,"html_url":"https://github.com/Eptwalabha/mustache","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/Eptwalabha%2Fmustache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eptwalabha%2Fmustache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eptwalabha%2Fmustache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eptwalabha%2Fmustache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eptwalabha","download_url":"https://codeload.github.com/Eptwalabha/mustache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245622961,"owners_count":20645679,"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","mustache","template"],"created_at":"2024-12-04T07:07:20.724Z","updated_at":"2025-03-26T08:44:39.980Z","avatar_url":"https://github.com/Eptwalabha.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mustache\n\n[![Erlang CI](https://github.com/Eptwalabha/mustache/actions/workflows/erlang.yml/badge.svg)](https://github.com/Eptwalabha/mustache/actions/workflows/erlang.yml)  \nCurrent version: `v0.2.0`\n\nA library to render [Mustach](https://mustache.github.io/) templates.  \nIt complies with the [Mustache's manual](https://mustache.github.io/mustache.5.html) and [specs](#specs).\n\n\u003e :warning: While all major features are present, this library is still under development. The following have yet to be added:\n\u003e - fetch template \u0026 partials from file\n\u003e - inheritancy\n\n## Usage\n\n``` erlang\n\u003e mustache:render(\"Hello {{wut}}!\", #{ wut =\u003e \"world\" }).\n\"Hello world!\"\n\u003e mustache:render(\u003c\u003c\"Hello {{wut}}!\"\u003e\u003e, [{ wut, \"world\" }]).\n\"Hello world!\"\n```\n\n## Sections and non-empty lists (and Strings)\n\nThe section **Non-Empty Lists** of the [manual](https://mustache.github.io/mustache.5.html#Sections), states that a section should be displayed as many time as there's element in the list.  \nThe problem is that erlang's strings [are lists](https://learnyousomeerlang.com/starting-out-for-real#highlighter_829076), which means that the following code will display as such:\n``` erlang\n\u003e Data = #{ string =\u003e \"hello\" }.\n\u003e mustache:render(\"{{#string}}oups!{{/string}}\", Data).\n\"oups!oups!oups!oups!oups!\"\n```\nUse binary to avoid this issue:\n``` erlang\n\u003e Data = #{ string =\u003e \u003c\u003c\"hello\"\u003e\u003e }.\n\u003e mustache:render(\"{{#string}}ok{{/string}}\", Data).\n\"ok\"\n```\n\n## Sections and Lambdas\n``` erlang\n\u003e Fun = fun (Template) -\u003e\n                % in here Template = \"hello {{name}}\",\n                \"\u003cstrong\u003e\" ++ Template ++ \"\u003c/strong\u003e\"\n        end.\n\u003e Map = #{ name =\u003e \"Tom\", lambda =\u003e Fun }.\n\u003e mustache:render(\"{{#lambda}}hello {{name}}{{/lambda}}\", Map).\n\"\u003cstrong\u003ehello Tom\u003c/strong\u003e\"\n```\n\n## Comments\nTags that begin with a bang (`!`) won't be displayed:\n``` erlang\n\u003e mustache:render(\"Hello{{! won't be displayed }}!\").\n\"Hello!\"\n```\n\n## Partials\nTags that begin with `\u003e` will include external template or \"partials\".\n\n`mustache:render` takes a third arguments for partials:\n``` erlang\n\u003e Template = \"ducks:\\n{{#ducks}}{{\u003eitem}}{{/ducks}}\".\n\u003e Map = #{ ducks =\u003e [\"Huey\", \"Dewey\", \"Louie\"] }.\n\u003e Partials = #{ item =\u003e \"- {{.}}\\n\" }.\n\u003e mustache:render(Template, Map, Partials).\n\"ducks:\\n- Huey\\n- Dewey\\n- Louie\\n\"\n```\n\n### From file\nIf not given to `render`, Partials will be directly fetched from file  \n\u003e This feature is comming soon\n\n## Specs\nThis library complies with the following specs:\n\n- [x] comments\n- [x] delimiters\n- [x] dynamic-names\n- [ ] inheritance\n- [x] interpolation\n- [x] inverted\n- [x] lambdas\n- [x] partials\n- [x] sections\n\n## Copyright\n\nThis repo is under the MIT's license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feptwalabha%2Fmustache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feptwalabha%2Fmustache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feptwalabha%2Fmustache/lists"}