{"id":23693236,"url":"https://github.com/stillpoint-software/hyperbee.templating","last_synced_at":"2025-09-02T20:33:52.306Z","repository":{"id":232396795,"uuid":"783891259","full_name":"Stillpoint-Software/hyperbee.templating","owner":"Stillpoint-Software","description":"A lightweight templating and variable substitution syntax engine that supports value replacements,  code expressions, token nesting, in-line definitions, conditional flow, and looping.","archived":false,"fork":false,"pushed_at":"2024-12-16T16:32:17.000Z","size":810,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-16T17:29:07.170Z","etag":null,"topics":["csharp","dotnet","template","template-engine","templates"],"latest_commit_sha":null,"homepage":"https://stillpoint-software.github.io/hyperbee.templating/","language":"C#","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/Stillpoint-Software.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":"2024-04-08T19:26:21.000Z","updated_at":"2024-11-25T20:55:54.000Z","dependencies_parsed_at":"2024-04-11T19:25:10.929Z","dependency_job_id":"b6d23e26-c3fb-4c7b-8d56-2b02d5586e54","html_url":"https://github.com/Stillpoint-Software/hyperbee.templating","commit_stats":null,"previous_names":["stillpoint-software/hyperbee.templating"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.templating","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.templating/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.templating/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stillpoint-Software%2Fhyperbee.templating/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stillpoint-Software","download_url":"https://codeload.github.com/Stillpoint-Software/hyperbee.templating/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231810738,"owners_count":18430003,"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":["csharp","dotnet","template","template-engine","templates"],"created_at":"2024-12-30T03:50:41.748Z","updated_at":"2025-09-02T20:33:52.291Z","avatar_url":"https://github.com/Stillpoint-Software.png","language":"C#","readme":"# Hyperbee Templating\n\nHyperbee Templating is a lightweight templating and variable substitution syntax engine. The library supports value replacements, \ncode expressions, token nesting, in-line definitions, conditional flow, and looping. It is designed to be lightweight and fast.\n\n## Features\n\n* Variable substitution syntax engine\n* Value replacements\n* Expression replacements\n* Token nesting\n* Conditional tokens\n* Conditional flow\n* Iterators\n* User-defined methods\n\n## Getting Started\n\nTo get started with Hyperbee.Templating, refer to the [documentation](https://stillpoint-software.github.io/hyperbee.templating) for \ndetailed instructions and examples. \n\nInstall via NuGet:\n\n```bash\ndotnet add package Hyperbee.Templating\n```\n\n## Basic Usage\n\n### Variable Substitution\n\nYou can use the `TemplateParser` to perform variable substitutions.\n\n```csharp\nvar template = \"hello {{name}}.\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"name\"] = \"me\"\n    }\n});\n\nConsole.WriteLine(result); // Output: hello me.\n```\n\n### Expression Substitution\n\n```csharp\nvar template = \"hello {{x =\u003e x.name.ToUpper()}}.\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"name\"] = \"me\"\n    }\n});\n\nConsole.WriteLine(result); // Output: hello ME.\n```\n\n### Token Nesting\n\nToken values can contain other tokens.\n\n```csharp\nvar template = \"hello {{fullname}}.\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"fullname\"] = \"{{first}} {{last}}\",\n        [\"first\"] = \"Hari\",\n        [\"last\"] = \"Seldon\"\n    }\n});\n\nConsole.WriteLine(result); // Output: hello Hari Seldon.\n```\n\n### Conditional Tokens\n\nYou can use conditional tokens to control the flow based on conditions.\n\n```csharp\nvar template = \"{{#if condition}}hello {{name}}.{{/if}}\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"condition\"] = \"true\",\n        [\"name\"] = \"me\"\n    }\n});\n\nConsole.WriteLine(result); // Output: hello me.\n```\n\n```csharp\nvar template = \"hello {{#if condition}}{{name1}}{{else}}{{name2}}{{/if}}.\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"condition\"] = \"false\",\n        [\"name1\"] = \"me\",\n        [\"name2\"] = \"you\",\n    }\n});\n\nConsole.WriteLine(result); // Output: hello you.\n```\n\n### While Statement\n\nYou can use a while statement to repeat a block of text while a condition is true.\n\n```csharp\nvar template = \"{{while x =\u003e x.counter\u003cint\u003e \u003c 3}}{{counter}}{{counter:{{x =\u003e x.counter\u003cint\u003e + 1}}}}{{/while}}\";\n\nvar result = Template.Render(template, new()\n{\n    Variables =\n    {\n        [\"counter\"] = \"0\"\n    }\n});\n\nConsole.WriteLine(result); // Output: 012. \n```\n\n### Each Statement\n\n```csharp\nvar template = \"{{each n:x =\u003e x.list.Split( \\\",\\\" )}}World {{n}},{{/each}}\";\n\nvar result = Template.Render(template, new()\n{\n    Variables = \n    { \n        [\"list\"] = \"John,James,Sarah\" \n    }\n});\n\nConsole.WriteLine(result); // hello World John,World James,World Sarah,. \n```\n\n```csharp\n\nvar template = \"{{each n:x =\u003e x.Where( t =\u003e Regex.IsMatch( t.Key, \\\"people*\\\" ) ).Select( t =\u003e t.Value )}}hello {{n}}. {{/each}}\";\n\nvar result = Template.Render(template, new()\n{\n    Variables = \n    {\n        [\"people[0]\"] = \"John\",\n        [\"people[1]\"] = \"Jane\",\n        [\"people[2]\"] = \"Doe\"\n    }\n});\n\nConsole.WriteLine(result); // hello John. hello Jane. hello Doe. \n```\n\n### Methods\n\nYou can invoke methods within token expressions.\n\n```csharp\nvar options = new TemplateOptions()\n    .AddVariable(\"name\", \"me\")\n    .AddMethod(\"ToUpper\").Expression\u003cstring,string\u003e( value =\u003e value.ToUpper() );\n\nvar template = \"hello {{x =\u003e x.ToUpper( x.name )}}.\";\n\nvar result = Template.Render(template, options);\n\nConsole.WriteLine(result); // Output: hello ME.\n```\n\n## Credits\n\nSpecial thanks to:\n\n- [Just The Docs](https://github.com/just-the-docs/just-the-docs) for the documentation theme.\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](https://github.com/Stillpoint-Software/.github/blob/main/.github/CONTRIBUTING.md) for more details.\n\n# Status\n\n| Branch     | Action                                                                                                                                                                                                                      |\n|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `develop`  | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Templating/actions/workflows/pack_publish.yml/badge.svg?branch=develop)](https://github.com/Stillpoint-Software/Hyperbee.Templating/actions/workflows/pack_publish.yml)  |\n| `main`     | [![Build status](https://github.com/Stillpoint-Software/Hyperbee.Templating/actions/workflows/pack_publish.yml/badge.svg)](https://github.com/Stillpoint-Software/Hyperbee.Templating/actions/workflows/pack_publish.yml)                 |\n\n# Help\n See [Todo](https://github.com/Stillpoint-Software/Hyperbee.Templating/blob/main/docs/todo.md)\n\n[![Hyperbee.Templating](https://github.com/Stillpoint-Software/Hyperbee.Templating/blob/main/assets/hyperbee.svg?raw=true)](https://github.com/Stillpoint-Software/Hyperbee.Templating)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillpoint-software%2Fhyperbee.templating","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstillpoint-software%2Fhyperbee.templating","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstillpoint-software%2Fhyperbee.templating/lists"}