{"id":17058796,"url":"https://github.com/jpvenson/morestachio","last_synced_at":"2025-08-20T18:56:36.941Z","repository":{"id":38146391,"uuid":"109896804","full_name":"JPVenson/morestachio","owner":"JPVenson","description":"Lightweight, powerful, flavorful, template engine.","archived":false,"fork":false,"pushed_at":"2024-12-01T00:22:00.000Z","size":3859,"stargazers_count":52,"open_issues_count":3,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-08-11T15:21:50.807Z","etag":null,"topics":["formatters","hacktoberfest","mustache","netstandard","stream","template-engine","templating"],"latest_commit_sha":null,"homepage":"","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/JPVenson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":["JPVenson"],"custom":["https://www.paypal.me/jeanpierrebachmann"]}},"created_at":"2017-11-07T22:09:16.000Z","updated_at":"2025-03-26T08:03:21.000Z","dependencies_parsed_at":"2024-06-02T20:59:26.867Z","dependency_job_id":"dbf1c09b-667f-4f73-a298-96caf6e2e111","html_url":"https://github.com/JPVenson/morestachio","commit_stats":{"total_commits":791,"total_committers":14,"mean_commits":56.5,"dds":0.4323640960809102,"last_synced_commit":"d75a02a627711dc8958859c63e7338c66d73033a"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/JPVenson/morestachio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPVenson%2Fmorestachio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPVenson%2Fmorestachio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPVenson%2Fmorestachio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPVenson%2Fmorestachio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JPVenson","download_url":"https://codeload.github.com/JPVenson/morestachio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPVenson%2Fmorestachio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271369101,"owners_count":24747790,"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-08-20T02:00:09.606Z","response_time":69,"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":["formatters","hacktoberfest","mustache","netstandard","stream","template-engine","templating"],"created_at":"2024-10-14T10:31:00.432Z","updated_at":"2025-08-20T18:56:36.861Z","avatar_url":"https://github.com/JPVenson.png","language":"C#","funding_links":["https://github.com/sponsors/JPVenson","https://www.paypal.me/jeanpierrebachmann"],"categories":[],"sub_categories":[],"readme":"# Morestachio \n![](https://img.shields.io/osslifecycle/JPVenson/morestachio)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FJPVenson%2Fmorestachio.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FJPVenson%2Fmorestachio?ref=badge_shield)\n[![Converage](https://img.shields.io/azure-devops/coverage/jeanpierrebachmann/Morestachio/3?label=Test%20Coverage)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_build?definitionId=3\u0026view=ms.vss-pipelineanalytics-web.new-build-definition-pipeline-analytics-view-cardmetrics)\n![tests](https://img.shields.io/azure-devops/tests/jeanpierrebachmann/Morestachio/3)\n\n\n![Icon](https://github.com/JPVenson/morestachio/blob/master/Morestachio/Morestachio%20248x248.png?raw=true)\n\nA Lightweight, powerful, flavorful, templating engine for C# and other .net-based languages. Its a fork of Mustachio.\n\n\n## Need help?\nNeed general help? open a [Discussion](https://github.com/JPVenson/morestachio/discussions/new)   \nFound a bug? open a [Bug](https://github.com/JPVenson/morestachio/issues/new?assignees=\u0026labels=\u0026template=bug_report.md)   \n\n#### Installing Morestachio:\n\n\n|Project Nuget|Github|Status|Description|\n|---|---|---|---|\n| Morestachio \u003cbr /\u003e [![Nuget Morestachio](https://img.shields.io/nuget/v/Morestachio?label=Morestachio)](https://www.nuget.org/packages/Morestachio/) ![](https://img.shields.io/nuget/dt/morestachio)  | [![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/JPVenson/morestachio?include_prereleases)](https://github.com/JPVenson/morestachio/releases) | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1)| The base Morestachio lib |\n| Morestachio.Linq \u003cbr /\u003e [![Nuget Morestachio Linq](https://img.shields.io/nuget/v/Morestachio.Linq?label=%20Morestachio.Linq)](https://www.nuget.org/packages/Morestachio.Linq/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.Linq) |   | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | [Linq formatter](https://github.com/JPVenson/morestachio/wiki/Predefined-Formatter#class-dynamiclinq) |\n| Morestachio.Runner \u003cbr /\u003e [![Nuget Morestachio Runner](https://img.shields.io/nuget/v/Morestachio.Runner?label=%20Morestachio.Runner)](https://www.nuget.org/packages/Morestachio.Runner/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.Runner) |   | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | An [executable interface](https://github.com/JPVenson/morestachio/wiki/Morestachio-Runner) for invoking a Morestachio Template |\n| Morestachio.Newtonsoft.Json \u003cbr /\u003e [![Nuget Morestachio Json](https://img.shields.io/nuget/v/Morestachio.Newtonsoft.Json?label=Morestachio.Newtonsoft.Json)](https://www.nuget.org/packages/Morestachio.Newtonsoft.Json/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.Newtonsoft.Json) |  | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | Newtonsoft Json [types support](https://github.com/JPVenson/morestachio/wiki/Newtonsoft.Json-support) |\n| Morestachio.System.Text.Json \u003cbr /\u003e [![Nuget Morestachio System.Text.Json](https://img.shields.io/nuget/v/Morestachio.System.Text.Json?label=Morestachio.System.Text.Json)](https://www.nuget.org/packages/Morestachio.System.Text.Json/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.System.Text.Json) |  | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | System.Text Json [types support](https://github.com/JPVenson/morestachio/wiki/System.Text.Json-support) |\n| Morestachio.System.Xml.Linq \u003cbr /\u003e [![Nuget Morestachio.System.Xml.Linq](https://img.shields.io/nuget/v/Morestachio.System.Xml.Linq?label=Morestachio.System.Xml.Linq)](https://www.nuget.org/packages/Morestachio.System.Xml.Linq/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.System.Xml.Linq) |  | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | XDocument [types support](https://github.com/JPVenson/morestachio/wiki/System.Xml-support) |\n| Morestachio.Extensions.Logging \u003cbr /\u003e [![Nuget Morestachio.Extensions.Logging](https://img.shields.io/nuget/v/Morestachio.Extensions.Logging?label=Morestachio.Extensions.Logging)](https://www.nuget.org/packages/Morestachio.Extensions.Logging/) \u003cbr /\u003e ![](https://img.shields.io/nuget/dt/morestachio.Extensions.Logging) |  | [![Build status](https://dev.azure.com/JeanPierreBachmann/Mustachio/_apis/build/status/Morestachio-CI%20DotNet)](https://dev.azure.com/JeanPierreBachmann/Mustachio/_build/latest?definitionId=3) [![Deployment Status](https://jeanpierrebachmann.vsrm.visualstudio.com/_apis/public/Release/badge/9c3dc1dc-4391-4970-b520-1713860906f7/1/1)](https://jeanpierrebachmann.visualstudio.com/Morestachio/_release?view=all\u0026_a=releases\u0026definitionId=1) | Microsoft.Extensions.Logging.ILogger [support]([https://github.com/JPVenson/morestachio/wiki/System.Xml-support](https://github.com/JPVenson/morestachio/wiki/Microsoft.Extensions.Logging)) |\n\n#### What's this for?\n\n*Morestachio* allows you to create simple text-based templates that are fast and safe to render. It is optimized for WebServers and offers a high degree of customization with its formatter syntax.\n\n#### Morestachio Playground:\nTry it out, without consequenses. The Morestachio online editor allows you to create templates within your browser:\n[Editor](https://morestachio.jean-pierre-bachmann.dev/)\n\n#### How to use Morestachio:\n\n```csharp\n// Your template\nvar sourceTemplate = \"Dear {{name}}, this is definitely a personalized note to you. Very truly yours, {{sender}}\";\n\n// Parse the template into the document tree. \nvar document = await ParserOptionsBuilder\n   .New() //creates a new builder that inherts all default values\n   .WithTemplate(sourceTemplate) //sets the template for that builder\n   .BuildAndParseAsync(); //Builds the template and calls ParseAsync() on the returned ParserOptions\n\n// Create the values for the template model:\ndynamic model = new ExpandoObject();\nmodel.name = \"John\";\nmodel.sender = \"Sally\";\n// or with dictionarys\nIDictionary model = new Dictionary\u003cstring, object\u003e();\nmodel[\"name\"] = \"John\";\nmodel[\"sender\"] = \"Sally\";\n//or with any other object\nvar model = new { name= \"John\", sender= \"Sally\" };\n\n//create an object based renderer or a compiled renderer\n//the renderer is reusable and ThreadSave\nvar renderer = document.CreateRenderer();\n\n// Render the template with your model and get the result as a string\nvar content = renderer.RenderAndStringify(model); // Dear John, this is definitely a personalized note to you. Very truly yours, Sally\n```\n\n\n##### Key Features\nMorestachio is build upon Mustachio and extends the mustachio syntax in a a lot of points.\n\n1. each object can be formatted by adding [formatter](https://github.com/JPVenson/morestachio/wiki/Formatter) to morestachio\n2. Templates will be parsed as [streams](https://github.com/JPVenson/morestachio/wiki/ParserOptions#template-itemplatecontainer-property) and will create a new stream for its [output](). This is better when creating larger templates and best for web as you can also [limit the length](https://github.com/JPVenson/morestachio/wiki/ParserOptions#maxsize-long-property) of the \"to be\" created template to a certain size and write the result ether directly to an output stream or the Disc.\n3. [Its Lightning fast](https://github.com/JPVenson/morestachio/wiki/Performance). Even unreasonably huge templates that contain \u003e5000 instructions can be executed in around *0.5 secounds*\n4. Morestachio accepts any object as source\n5. [Cancellation](https://github.com/JPVenson/morestachio/wiki/ParserOptions#timeout-timespan-property) of Template generation is supported\n6. Async calls are supported (For Formatters)\n7. No External Depedencies for Morestachio.dll.\n8. Support for several .Net framworks:\n   - NetStandard (netstandard2.0; netstandard2.1; see [.NET implementation support](https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support)) \n   - Net5.0, Net6.0\n9. Build in [Localization support](https://github.com/JPVenson/morestachio/wiki/Localisation) and [Logging support](https://github.com/JPVenson/morestachio/wiki/ParserOptions#logger-ilogger-property)\n10. Supports user [Encoding](https://github.com/JPVenson/morestachio/wiki/ParserOptions#encoding-encoding-property) of the result template\n11. Supports [Template Partials](https://github.com/JPVenson/morestachio/wiki/Templates-Partials) `{{#import 'secondary_template' }}`\n12. [Complex paths](https://github.com/JPVenson/morestachio/wiki/Keywords#paths) are supported `{{ this.is.a.valid.path }}` and `{{ ../this.goes.up.one.level }}` and `{{ ~.this.goes.up.to.Root }}`\n13. [Loops](https://github.com/JPVenson/morestachio/wiki/Keywords#do--while--repeat---blocks) with `#each` \u0026 `#do` \u0026 `#while` \u0026 `#repeat`\n14. [Object Enumeration](https://github.com/JPVenson/morestachio/wiki/Keywords#each--every---blocks) with `#each data.?`\n15. Formatters can be declared in C# and be called from the template to provide you with a maximum of freedom\n16. Extensive (275) [Build-In list of Formatters](https://github.com/JPVenson/morestachio/wiki/Predefined-Formatter) for a broad usecases\n17. The Parser produces a Serilizable [Document Tree](https://github.com/JPVenson/morestachio/wiki/Document-Tree) that can be send to clients to provide a rich user edit experience \n\nCheckout the Github Wiki for an extensive documentation:\nhttps://github.com/JPVenson/morestachio/wiki\n \n**Template partials** ARE a great feature for large scale template development.\n\nYou can create a Partial with the `{{#declare NAME}}Partial{{/declare}}` syntax. You can navigate up inside this partials. Partials can also be nested but are currently restricted to a maximum recursion of 255 depth. The programmer has the choice to define a behavior that ether throws an Exception or does nothing and ignores any deeper recusions.    \n\nA Partial must be declared before its usage with `{{#import 'NAME'}}` but you can use a partial to create hirarical templates.    \n\nYou can even inject your predefined Partials into all of your Templates by utilizing the `PartialsStore`. Use your own `IPartialStore` or a build in one with `ParserOptionsBuilder.WithDefaultPartialStore(store =\u003e {...add partials to store...})`.\n\n###### Infos about new features\n \nIts possible to use plain C# objects they will be called by reflection. \nAlso you can now set the excact size of the template to limit it (this could be come handy if you are in a hostet environment) use the `ParserOptionsBuilder.WithMaxSize()` option to define a max size. It will be enforced on exact that amount of bytes in the stream.\n\n##### Variable Output\nOne mayor component is the usage of Variable output strategies in morestachio.    \nThe output handling is done by a `IByteCounterStream` that wraps your specific output. This can ether be a `Stream`, `TextWriter`, `StringBuilder` or anything else. For thoese types Morestachio has pre defined Implementations named `ByteCounterStream`, `ByteCounterTextWriter` and `ByteCounterStringBuilder`. All thoese types are enforcing the `ParserOptionsBuilder.WithMaxSize()` config if set and will write your template with the set `ParserOptionsBuilder.WithEncoding()`\n \n###### Formatter\nWith Morestachio you can invoke C# methods from you template, so called 'Formatters'. There are [Build in formatters](https://github.com/JPVenson/morestachio/wiki/Predefined-Formatter) you can call in any template, registered via the `DefaultFormatterService.Default` class. When you add a formatter in the default service, it will be availible in every template. You can also add formatters per-template via the `ParserOptionsBuilder.WithFormatters` service.\n\nTo Invoke a formatter from you template use the Function syntax:\n```csharp\n{{Just.One.Formattable.FormatterToCall().Thing}}\n```\nThis links a c# function named \"FormatterToCall\".\n\nYou can register delegates by using `ParserOptionsBuilder.WithFormatter(...)` or you can create a `public static class` that has methods attributed with the `MorestachioFormatterAttribute` and add them via the `ParserOptionsBuilder.WithFormatters\u003cTType\u003e` or you can use an instance method attributed with the `MorestachioFormatterAttribute`.\n\nThe formatter CAN return a new object on wich you can call new Propertys or it can return a string.\nThere are formatter prepaired for types implementing the `IFormattable` interface. This includes all Primitve types. That means for example that you can call the `ToString` formatter on any `DateTime`:\n```csharp\n{{MyObject.DateTime.ToString(\"D\")}} \u003c-- this will resolve a property \"MyObject\" and then \"DateTime\" and will call ToString on it with the argument \"D\"\n```\n\n**Formatter References** \nCan be used to reference another property/key in the template and then use it in a Formatter. Everything that is not a string (ether prefixed and suffixed with \" or ') will be threaded as an expression that also can contain formatter calls\n```csharp\n{{MyObject.Value.ToString(Key)}}\n```\nThis will call a formatter that is resposible for the type that `Value` has and will give it whats in `Key`. Example:\n```csharp\n//create the template\nvar template = \"{{Value.ToStringX(Key)}}\";\n//create the model\nvar model = new Dictionary\u003cstring, object\u003e();\nmodel[\"Value\"] = DateTime.Now; \nmodel[\"Key\"] = \"D\";\n//now add a formatter for our DateTime and add it to the ParserOptions\n\nvar document = await ParserOptionsBuilder\n   .New()\n   .WithTemplate(template)\n//                         Value   | Argument | Return\n   .WithFormatter(new Func\u003cDateTime, string   , string\u003e((value, argument) =\u003e {\n     //value will be the DateTime object and argument will be the value from Key\n     return value.ToString(argument);\n   }, \"ToStringX\")\n   .BuildAndParseAsync();\n\ndocument.CreateRenderer().RenderAndStringify(model); // Friday, September 21, 2018 ish\n\n```\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FJPVenson%2Fmorestachio.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FJPVenson%2Fmorestachio?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpvenson%2Fmorestachio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpvenson%2Fmorestachio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpvenson%2Fmorestachio/lists"}