{"id":19351702,"url":"https://github.com/operable/greenbar","last_synced_at":"2025-04-23T07:31:06.173Z","repository":{"id":78638254,"uuid":"66484621","full_name":"operable/greenbar","owner":"operable","description":"A flexible templating engine based on Markdown","archived":false,"fork":false,"pushed_at":"2017-09-23T03:13:03.000Z","size":225,"stargazers_count":5,"open_issues_count":4,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T09:44:56.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/operable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2016-08-24T17:21:21.000Z","updated_at":"2023-09-10T08:49:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"01705427-c4ae-4398-92e3-8f1b7f354911","html_url":"https://github.com/operable/greenbar","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operable%2Fgreenbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operable%2Fgreenbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operable%2Fgreenbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/operable%2Fgreenbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/operable","download_url":"https://codeload.github.com/operable/greenbar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391133,"owners_count":21422846,"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":[],"created_at":"2024-11-10T04:36:59.524Z","updated_at":"2025-04-23T07:31:06.165Z","avatar_url":"https://github.com/operable.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Greenbar: The meta-template processor\n\n[![Build Status](https://travis-ci.org/operable/greenbar.svg?branch=master)](https://travis-ci.org/operable/greenbar)\n[![Coverage Status](https://coveralls.io/repos/github/operable/greenbar/badge.svg?branch=master)](https://coveralls.io/github/operable/greenbar?branch=master)\n[![Ebert](https://ebertapp.io/github/operable/greenbar.svg)](https://ebertapp.io/github/operable/greenbar)\n\nStandard template processors like erb, mustache, and eex return formatted output when they process a template.\nNormally this is just fine as most applications use common formats like HTML or JSON for their outputs.\n\nMeta-templates, templates which produce other templates, are useful when an application needs to support multiple\nformats and/or format(s) which are unevenly implemented (Markdown I'm looking at you). This is the problem domain\nGreenbar was designed to address.\n\n### For the truly curious\n\nWe created Greenbar to improve [Cog](https://github.com/operable/cog)'s rendering abilities. Generating attractive\nand uniform content across multiple chat providers is quite challenging and also vital to building a good user\nexperience.\n\n## How Does It Work?\n\nGreenbar templates use a combination of Markdown and custom Greenbar-specific tags to describe a template. Templates\nare compiled to executable Elixir code and then cached for easy reuse. Executing a template generates a list of\ndirectives which describe how to build the final output.\n\n## Your First Template\n\nHere's a simple template that says hello:\n\n```\nHello ~$user~!\n\nHave a __GREAT__ DAY!\n```\n\nAfter downloading and building Greenbar you can build the template like so:\n\n```\niex(1)\u003e template = \"\"\"\n...(1)\u003e Hello ~$user~!\n...(1)\u003e\n...(1)\u003e Have a __GREAT__ DAY!\n...(1)\u003e \"\"\"\n\"Hello ~$user~!\\n\\nHave a __GREAT__ DAY!\\n\"\niex(2)\u003e {:ok, engine} = Greenbar.Engine.new\n{:ok,\n %Greenbar.Engine{tags: %{\"br\" =\u003e Greenbar.Tags.Break,\n    \"count\" =\u003e Greenbar.Tags.Count, \"each\" =\u003e Greenbar.Tags.Each,\n    \"title\" =\u003e Greenbar.Tags.Title}, templates: %{}}}\niex(3)\u003e engine = Greenbar.Engine.compile!(engine, \"hello\", template)\n%Greenbar.Engine{tags: %{\"br\" =\u003e Greenbar.Tags.Break,\n   \"count\" =\u003e Greenbar.Tags.Count, \"each\" =\u003e Greenbar.Tags.Each,\n   \"title\" =\u003e Greenbar.Tags.Title},\n templates: %{\"hello\" =\u003e %Greenbar.Template{debug_source: nil,\n    hash: \"c8c61d458c8070f04d76cb3e07dffcbd7dd0965080dba7f406b7b5c8a123dc5f\",\n    name: \"hello\", source: \"Hello ~$user~!\\n\\nHave a __GREAT__ DAY!\\n\",\n    template_fn: #Function\u003c12.54118792/2 in :erl_eval.expr/5\u003e,\n    timestamp: 1472755224456112954}}}\n```\n\nLet's execute the compiled template:\n\n```\niex(4)\u003e Greenbar.Engine.eval!(engine, \"hello\", %{\"user\" =\u003e \"Zaphod\"})\n[%{name: :text, text: \"Hello Zaphod!\"}, %{name: :newline},\n %{name: :text, text: \"Have a \"}, %{name: :bold, text: \"GREAT\"},\n %{name: :text, text: \" DAY!\"}]\n```\n\n## Syntax\n\nStandard Markdown notation for emphasis, strong, code line, and code blocks are implemented. Tables and (un)ordered lists\nare coming soon.\n\nTemplate variables and tags are referenced using tildes. See [test/support/templates.ex](https://github.com/operable/greenbar/blob/master/test/support/templates.ex) for more examples.\n\n## Tags\n\nGreenbar tags are designed to be extensible. See [lib/greenbar/tag.ex](https://github.com/operable/greenbar/blob/master/lib/greenbar/tag.ex) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperable%2Fgreenbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foperable%2Fgreenbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foperable%2Fgreenbar/lists"}