{"id":22353032,"url":"https://github.com/esskar/handlebars-core","last_synced_at":"2025-10-07T02:18:32.380Z","repository":{"id":136980973,"uuid":"90456347","full_name":"esskar/handlebars-core","owner":"esskar","description":"***DEPRECATED*** A real .NET Handlebars engine.","archived":false,"fork":false,"pushed_at":"2017-05-08T17:18:42.000Z","size":1347,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T01:43:54.485Z","etag":null,"topics":["handlebars","handlebars-js","handlebars-template","mustache","mustache-templating"],"latest_commit_sha":null,"homepage":"","language":"C#","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/esskar.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":"2017-05-06T10:47:25.000Z","updated_at":"2021-02-09T16:24:16.000Z","dependencies_parsed_at":"2023-03-22T12:17:13.048Z","dependency_job_id":null,"html_url":"https://github.com/esskar/handlebars-core","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/esskar/handlebars-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esskar%2Fhandlebars-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esskar%2Fhandlebars-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esskar%2Fhandlebars-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esskar%2Fhandlebars-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/esskar","download_url":"https://codeload.github.com/esskar/handlebars-core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/esskar%2Fhandlebars-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708004,"owners_count":26031932,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["handlebars","handlebars-js","handlebars-template","mustache","mustache-templating"],"created_at":"2024-12-04T12:32:28.765Z","updated_at":"2025-10-07T02:18:32.342Z","avatar_url":"https://github.com/esskar.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Handlebars for .NET [![Build Status](https://travis-ci.org/esskar/handlebars-core.svg?branch=master)](https://travis-ci.org/esskar/handlebars-core)\n===================\n\nAmazing [Handlebars templates](http://handlebarsjs.com) in your .NET application.\n\n\u003eHandlebars.js is an extension to the Mustache templating language created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.\n\nCheck out the [handlebars.js documentation](http://handlebarsjs.com) for how to write Handlebars templates.\n\nHandlebars doesn't use a scripting engine to run a Javascript library - it compiles Handlebars templates directly into executable code and produces a delegate that represents the template.\n\n## Install\n\n    nuget install Handlebars.Core\n\n## Usage\n\n```c#\nstring source =\n@\"\u003cdiv class=\"\"entry\"\"\u003e\n  \u003ch1\u003e{{title}}\u003c/h1\u003e\n  \u003cdiv class=\"\"body\"\"\u003e\n    {{body}}\n  \u003c/div\u003e\n\u003c/div\u003e\";\n\nvar handlebars = new HandlebarsEngine();\nvar template = handlebars.Compile(source);\n\nvar data = new {\n    title = \"My new post\",\n    body = \"This is my first post!\"\n};\n\nvar result = template.Render(data);\n\n/* Would render:\n\u003cdiv class=\"entry\"\u003e\n  \u003ch1\u003eMy New Post\u003c/h1\u003e\n  \u003cdiv class=\"body\"\u003e\n    This is my first post!\n  \u003c/div\u003e\n\u003c/div\u003e\n*/\n```\n\n### Registering Partials\n\n```c#\nstring source =\n@\"\u003ch2\u003eNames\u003c/h2\u003e\n{{#names}}\n  {{\u003e user}}\n{{/names}}\";\n\nstring partialSource =\n@\"\u003cstrong\u003e{{name}}\u003c/strong\u003e\";\n\nvar handlebars = new HandlebarsEngine();\nhandlebars.RegisterTemplate(\"user\", partialSource);\n\nvar template = handlebars.Compile(source);\n\nvar data = new {\n  names = new [] {\n    new {\n        name = \"Karen\"\n    },\n    new {\n        name = \"Jon\"\n    }\n  }\n};\n\nvar result = template.Render(data);\n\n/* Would render:\n\u003ch2\u003eNames\u003c/h2\u003e\n  \u003cstrong\u003eKaren\u003c/strong\u003e\n  \u003cstrong\u003eJon\u003c/strong\u003e\n*/\n```\n\n### Using TemplateContentProvider\n\nIf you want to keep your templates in the filesystem or in a database \nyou can implement the ITemplateContentProvider interface to retrieve your template from everywhere you like.\n\n* [FileSystemTemplateContentProvider](https://github.com/esskar/handlebars-contentprovider-filesystem)\n\n### Registering Helpers\n\n```c#\nvar handlebars = new HandlebarsEngine();\nhandlebars.RegisterHelper(\"link_to\", (writer, context, parameters) =\u003e {\n  writer.WriteSafeString(\"\u003ca href='\" + context.url + \"'\u003e\" + context.text + \"\u003c/a\u003e\");\n});\n\nstring source = @\"Click here: {{link_to}}\";\n\nvar template = handlebars.Compile(source);\n\nvar data = new {\n    url = \"https://github.com/rexm/handlebars.net\",\n    text = \"Handlebars.Net\"\n};\n\nvar result = template.Render(data);\n\n/* Would render:\nClick here: \u003ca href='https://github.com/rexm/handlebars.net'\u003eHandlebars.Net\u003c/a\u003e\n*/\n```\n\n## Performance\n\n### Compilation\n\nCompared to rendering, compiling is a fairly intensive process. While both are still measured in millseconds, compilation accounts for the most of that time by far. So, it is generally ideal to compile once and cache the resulting function to be re-used for the life of your process.\n\n### Model Types\nDifferent types of objects have different performance characteristics when used as models.\n- For example, the absolute fastest model is a dictionary (microseconds), because no reflection is necessary at render time.\n- The next fastest is a POCO (typically a few milliseconds for an average-sized template and model), which uses traditional reflection and is fairly fast.\n- Rendering starts to get slower (into the tens of milliseconds or more) on dynamic objects.\n- The slowest (up to hundreds of milliseconds or worse) tend to be objects with custom type implementations (such as `ICustomTypeDescriptor`) that are not optimized for heavy reflection.\n\nA frequent performance issue that comes up is JSON.NET's `JObject`, which for reasons we haven't fully researched, has very slow reflection characteristics when used as a model in Handlebars.Net. A simple fix is to just use JSON.NET's built-in ability to deserialize a JSON string to an `ExpandoObject` instead of a `JObject`. This will yield nearly an order of magnitude improvement in render times on average.\n\n## Future roadmap\n\n- [ ] **Add unit tests!**\n- [x] [Support for sub-expressions](https://github.com/rexm/Handlebars.Net/issues/48)\n- [ ] `lookup` and `helperMissing` helpers\n- [x] [Support for whitespace control](https://github.com/rexm/Handlebars.Net/issues/52)\n- [ ] MVC view engine\n- [ ] Nancy view engine\n\n## Contributing\n\nPull requests are welcome! The guidelines are pretty straightforward:\n- Only add capabilities that are already in the Mustache / Handlebars specs\n- Avoid dependencies outside of the .NET BCL\n- Maintain cross-platform compatibility (.NET/Mono; Windows/OSX/Linux/etc)\n- Follow the established code format\n\n## Thanks\n\nThis project was originally cloned from [Handlebars.Net](https://github.com/rexm/Handlebars.Net).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesskar%2Fhandlebars-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesskar%2Fhandlebars-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesskar%2Fhandlebars-core/lists"}