{"id":13509129,"url":"https://github.com/soranoba/bbmustache","last_synced_at":"2025-05-16T06:07:30.730Z","repository":{"id":27444552,"uuid":"30922962","full_name":"soranoba/bbmustache","owner":"soranoba","description":"Binary pattern match Based Mustache template engine for Erlang/OTP.","archived":false,"fork":false,"pushed_at":"2024-05-29T04:48:37.000Z","size":5992,"stargazers_count":185,"open_issues_count":1,"forks_count":51,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-08T16:04:37.715Z","etag":null,"topics":["erlang","mustache","template-engine"],"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/soranoba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["soranoba"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://paypal.me/soranoba"]}},"created_at":"2015-02-17T15:26:13.000Z","updated_at":"2025-03-13T04:46:28.000Z","dependencies_parsed_at":"2024-05-01T17:21:17.304Z","dependency_job_id":"21300d69-816a-4470-937b-45dc128658bc","html_url":"https://github.com/soranoba/bbmustache","commit_stats":{"total_commits":168,"total_committers":9,"mean_commits":"18.666666666666668","dds":0.125,"last_synced_commit":"31e94ffd9618accd8e6604c7d5c3235363f5c5dd"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soranoba%2Fbbmustache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soranoba%2Fbbmustache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soranoba%2Fbbmustache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soranoba%2Fbbmustache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soranoba","download_url":"https://codeload.github.com/soranoba/bbmustache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478190,"owners_count":22077676,"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-engine"],"created_at":"2024-08-01T02:01:03.337Z","updated_at":"2025-05-16T06:07:25.717Z","avatar_url":"https://github.com/soranoba.png","language":"Erlang","funding_links":["https://github.com/sponsors/soranoba","https://paypal.me/soranoba"],"categories":["Templating"],"sub_categories":[],"readme":"bbmustache\n===========\n[![CircleCI](https://circleci.com/gh/soranoba/bbmustache/tree/master.svg?style=svg)](https://circleci.com/gh/soranoba/bbmustache/tree/master)\n[![hex.pm version](https://img.shields.io/hexpm/v/bbmustache.svg)](https://hex.pm/packages/bbmustache)\n\nBinary pattern match Based Mustache template engine for Erlang/OTP.\n\n## Overview\n- Binary pattern match based mustache template engine for Erlang/OTP.\n  - It means do not use regular expressions.\n- Support maps and associative arrays.\n- Officially support is OTP24 or later.\n\n### What is Mustache ?\nA logic-less templates.\n- [{{mustache}}](http://mustache.github.io/)\n\n## Usage\n### Quick start\n\n```bash\n$ git clone https://github.com/soranoba/bbmustache.git\n$ cd bbmustache\n$ make start\nErlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:true]\n\nEshell V6.3  (abort with ^G)\n1\u003e bbmustache:render(\u003c\u003c\"{{name}}\"\u003e\u003e, #{\"name\" =\u003e \"hoge\"}).\n\u003c\u003c\"hoge\"\u003e\u003e\n2\u003e bbmustache:render(\u003c\u003c\"{{name}}\"\u003e\u003e, [{\"name\", \"hoge\"}]).\n\u003c\u003c\"hoge\"\u003e\u003e\n```\n\n### Use as a library\nAdd the following settings.\n\n```erlang\n%% rebar (rebar.config)\n\n{deps,\n  [\n   {bbmustache, \".*\", {git, \"https://github.com/soranoba/bbmustache.git\", {branch, \"master\"}}}\n  ]}.\n\n%% rebar3 (rebar.config)\n\n{deps, [bbmustache]}.\n```\n\n### How to use simple Mustache\n\nMap\n```erlang\n1\u003e bbmustache:render(\u003c\u003c\"{{name}}\"\u003e\u003e, #{\"name\" =\u003e \"hoge\"}).\n\u003c\u003c\"hoge\"\u003e\u003e\n\n2\u003e Template1 = bbmustache:parse_binary(\u003c\u003c\"{{name}}\"\u003e\u003e).\n...\n3\u003e bbmustache:compile(Template1, #{\"name\" =\u003e \"hoge\"}).\n\u003c\u003c\"hoge\"\u003e\u003e\n\n4\u003e Template2 = bbmustache:parse_file(\u003c\u003c\"./hoge.mustache\"\u003e\u003e).\n...\n5\u003e bbmustache:compile(Template2, #{\"name\" =\u003e \"hoge\"}).\n\u003c\u003c\"hoge\"\u003e\u003e\n```\n\nAssociative array\n```erlang\n1\u003e bbmustache:render(\u003c\u003c\"{{name}}\"\u003e\u003e, [{\"name\", \"hoge\"}]).\n\u003c\u003c\"hoge\"\u003e\u003e\n\n2\u003e Template1 = bbmustache:parse_binary(\u003c\u003c\"{{name}}\"\u003e\u003e).\n...\n3\u003e bbmustache:compile(Template1, [{\"name\", \"hoge\"}]).\n\u003c\u003c\"hoge\"\u003e\u003e\n\n4\u003e Template2 = bbmustache:parse_file(\u003c\u003c\"./hoge.mustache\"\u003e\u003e).\n...\n5\u003e bbmustache:compile(Template2, [{\"name\", \"hoge\"}]).\n\u003c\u003c\"hoge\"\u003e\u003e\n```\n\n### Use as a command-line tool\n\n```bash\nmake escriptize\necho '{\"name\", \"hoge\"}.' \u003e vars.config\necho '{{name}}' \u003e template.mustache\n./bbmustache -d vars.config template.mustache\nhoge\n```\n\nData files (-d) support a single assoc list, a single map, and [consult](https://erlang.org/doc/man/file.html#consult-1) format.\u003cbr\u003e\nNote: the behind term has a high priority in all cases. it is a result of supporting to allow for embedding relative file paths as in [config](http://erlang.org/doc/man/config.html).\n\n### More information\n- For the alias of mustache, Please refer to [ManPage](http://mustache.github.io/mustache.5.html) and [Specification](https://github.com/mustache/spec)\n- For the options of this library, please see [doc](doc)\n- For the functions supported by this library, please see [here](benchmarks/README.md)\n\n## FAQ\n\n### Avoid http escaping\n\n```erlang\n%% Please use `{{{tag}}}`\n1\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{{title}}}\u003c/h1\u003e\"\u003e\u003e, #{\"title\" =\u003e \"I like Erlang \u0026 mustache\"}).\n\u003c\u003c\"\u003ch1\u003eI like Erlang \u0026 mustache\u003c/h1\u003e\"\u003e\u003e\n\n%% If you should not want to use `{{{tag}}}`, escape_fun can be use.\n1\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{title}}\u003c/h1\u003e\"\u003e\u003e, #{\"title\" =\u003e \"I like Erlang \u0026 mustache\"}, [{escape_fun, fun(X) -\u003e X end}]).\n\u003c\u003c\"\u003ch1\u003eI like Erlang \u0026 mustache\u003c/h1\u003e\"\u003e\u003e\n```\n\n### Already used `{` and `}` for other uses (like escript)\n\n```erlang\n1\u003e io:format(bbmustache:render(\u003c\u003c\"\n1\u003e {{=\u003c\u003c \u003e\u003e=}}\n1\u003e {deps, [\n1\u003e   \u003c\u003c#deps\u003e\u003e\n1\u003e   {\u003c\u003cname\u003e\u003e, \\\"\u003c\u003cversion\u003e\u003e\\\"}\u003c\u003c^last?\u003e\u003e,\u003c\u003c/last?\u003e\u003e\n1\u003e   \u003c\u003c/deps\u003e\u003e\n1\u003e ]}.\n1\u003e \"\u003e\u003e, #{\"deps\" =\u003e [\n1\u003e   #{\"name\" =\u003e \"bbmustache\", \"version\" =\u003e \"1.6.0\"},\n1\u003e   #{\"name\" =\u003e \"jsone\", \"version\" =\u003e \"1.4.6\", \"last?\" =\u003e true}\n1\u003e ]})).\n\n{deps, [\n  {bbmustache, \"1.6.0\"},\n  {jsone, \"1.4.6\"}\n]}.\nok\n```\n\n### Want to use something other than string for key\n\n```erlang\n1\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{{title}}}\u003c/h1\u003e\"\u003e\u003e, #{title =\u003e \"I like Erlang \u0026 mustache\"}, [{key_type, atom}]).\n\u003c\u003c\"\u003ch1\u003eI like Erlang \u0026 mustache\u003c/h1\u003e\"\u003e\u003e\n\n2\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{{title}}}\u003c/h1\u003e\"\u003e\u003e, #{\u003c\u003c\"title\"\u003e\u003e =\u003e \"I like Erlang \u0026 mustache\"}, [{key_type, binary}]).\n\u003c\u003c\"\u003ch1\u003eI like Erlang \u0026 mustache\u003c/h1\u003e\"\u003e\u003e\n```\n\n### Want to provide a custom serializer for Erlang Terms\n\n```erlang\n1\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{title}}\u003c/h1\u003e\"\u003e\u003e, #{title =\u003e \"I like Erlang \u0026 mustache\"}, [{key_type, atom}, {value_serializer, fun(X) -\u003e X end}]).\n\u003c\u003c\"\u003ch1\u003eI like Erlang \u0026amp; mustache\u003c/h1\u003e\"\u003e\u003e\n\n2\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{{title}}}\u003c/h1\u003e\"\u003e\u003e, #{\u003c\u003c\"title\"\u003e\u003e =\u003e \"I like Erlang \u0026 mustache\"}, [{key_type, binary}, {value_serializer, fun(X) -\u003e \u003c\u003c\"replaced\"\u003e\u003e end}]).\n\u003c\u003c\"\u003ch1\u003ereplaced\u003c/h1\u003e\"\u003e\u003e\n\n3\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{{title}}}\u003c/h1\u003e\"\u003e\u003e, #{\u003c\u003c\"title\"\u003e\u003e =\u003e #{\u003c\u003c\"nested\"\u003e\u003e =\u003e \u003c\u003c\"value\"\u003e\u003e}}, [{key_type, binary}, {value_serializer, fun(X) -\u003e jsone:encode(X) end}]).\n\u003c\u003c\"\u003ch1\u003e{\\\"nested\\\": \\\"value\\\"}\u003c/h1\u003e\"\u003e\u003e\n\n4\u003e bbmustache:render(\u003c\u003c\"\u003ch1\u003e{{title}}\u003c/h1\u003e\"\u003e\u003e, #{\u003c\u003c\"title\"\u003e\u003e =\u003e #{\u003c\u003c\"nested\"\u003e\u003e =\u003e \u003c\u003c\"value\"\u003e\u003e}}, [{key_type, binary}, {value_serializer, fun(X) -\u003e jsone:encode(X) end}]).\n\u003c\u003c\"\u003ch1\u003e{\u0026quot;nested\u0026quot;:\u0026quot;value\u0026quot;}\u003c/h1\u003e\"\u003e\u003e\n```\n\n## Attention\n- Lambda expression is included wasted processing.\n  - Because it is optimized to `parse_binary/1` + `compile/2`.\n\n## Comparison with other libraries\n[Benchmarks and check the reference implementation](benchmarks/README.md)\n\n## Contribute\nPull request is welcome =D\n\n## License\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoranoba%2Fbbmustache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoranoba%2Fbbmustache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoranoba%2Fbbmustache/lists"}