{"id":19270786,"url":"https://github.com/activecampaign/mustachio","last_synced_at":"2025-04-09T14:10:09.508Z","repository":{"id":34651475,"uuid":"38620118","full_name":"ActiveCampaign/mustachio","owner":"ActiveCampaign","description":"Lightweight, powerful, flavorful, template engine.","archived":false,"fork":false,"pushed_at":"2024-04-10T17:44:21.000Z","size":581,"stargazers_count":209,"open_issues_count":14,"forks_count":18,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-02T06:55:16.683Z","etag":null,"topics":[],"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/ActiveCampaign.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":"2015-07-06T13:19:22.000Z","updated_at":"2025-01-16T23:19:00.000Z","dependencies_parsed_at":"2024-06-18T15:23:34.608Z","dependency_job_id":"ee3dd2de-b972-43a2-b5df-ae1f76892565","html_url":"https://github.com/ActiveCampaign/mustachio","commit_stats":null,"previous_names":["wildbit/mustachio"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveCampaign%2Fmustachio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveCampaign%2Fmustachio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveCampaign%2Fmustachio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ActiveCampaign%2Fmustachio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ActiveCampaign","download_url":"https://codeload.github.com/ActiveCampaign/mustachio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054194,"owners_count":21039952,"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-09T20:27:23.149Z","updated_at":"2025-04-09T14:10:09.424Z","avatar_url":"https://github.com/ActiveCampaign.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://newsletter.postmarkapp.com/assets/images/open-source/mustachio-logo@2x.png\" alt=\"Mustachio Logo\" title=\"Pistachio + Mustache =\u0026gt; Mustachio\" width=\"148\" height=\"149\"\u003e\n\n# Mustachio\n\n[![Nuget](https://img.shields.io/nuget/v/Mustachio)](https://www.nuget.org/packages/Mustachio/)\n\nA lightweight, powerful, templating engine for C# and other .net-based languages.\n\n#### What's this for?\n\n*Mustachio* allows you to create simple text-based templates that are fast and safe to render. It's the heart of [Postmark Templates](https://postmarkapp.com/blog/special-delivery-postmark-templates), and we're ecstatic to provide it as Open Source to the .net community.\n\n#### How to use Mustachio:\n\n```csharp\n// Parse the template:\nvar sourceTemplate = \"Dear {{name}}, this is definitely a personalized note to you. Very truly yours, {{sender}}\"\nvar template = Mustachio.Parser.Parse(sourceTemplate);\n\n// Create the values for the template model:\ndynamic model = new ExpandoObject();\nmodel.name = \"John\";\nmodel.sender = \"Sally\";\n\n// Combine the model with the template to get content:\nvar content = template(model);\n```\n#### Extending Mustachio with Token Expanders:\n\n```csharp\n// You can add support for Partials via Token Expanders.\n// Token Expanders can be used to extend Mustachio for many other use cases, such as: Date/Time formatters, Localization, etc., allowing also custom Token Render functions.\n\nvar sourceTemplate = \"Welcome to our website! {{{ @content }}} Yours Truly, John Smith.\";\nvar stringData = \"This is a partial. You can also add variables here {{ testVar }} or use other expanders. Watch out for infinite loops!\";\nvar tokenExpander = new TokenExpander\n    {\n        RegEx = new Regex(\"{{{ @content }}}\"), // you can also use Mustache syntax: {{\u003e content }}\n        ExpandTokens = (s, baseOptions) =\u003e Tokenizer.Tokenize(stringData, baseOptions) // Instead of baseOptions, you can pass a new ParsingOptions object, which has no TokenExpanders to avoid infinite loops.\n    };\nvar parsingOptions = new ParsingOptions { TokenExpanders = new[] { tokenExpander } };\nvar template = Mustachio.Parser.Parse(sourceTemplate, parsingOptions);\n\n// Create the values for the template model:\ndynamic model = new ExpandoObject();\nmodel.testVar = \"Test\";\n\n// Combine the model with the template to get content:\nvar content = template(model);\n```\n#### Installing Mustachio:\n\nMustachio can be installed via [NuGet](https://www.nuget.org/packages/Mustachio/):\n\n```bash\nInstall-Package Mustachio\n```\n\n##### Key differences between Mustachio and [Mustache](https://mustache.github.io/)\n\nMustachio contains a few modifications to the core Mustache language that are important.\n\n1. `each` blocks are recommended for handling arrays of values. (We have a good reason!)\n2. Complex paths are supported, for example `{{ this.is.a.valid.path }}` and `{{ ../this.goes.up.one.level }}`\n3. Template partials are supported via Token Expanders.\n \n###### A little more about the differences:\n\nOne awesome feature of Mustachio is that with a minor alteration in the mustache syntax, we can infer what model will be required to completely fill out a template. By using the `each` keyword when interating over an array, our parser can infer whether an array or object (or scalar) should be expected when the template is used. Normal mustache syntax would prevent us from determining this.\n\nWe think the model inference feature is compelling, because it allows for error detection, and faster debugging iterations when developing templates, which justifies this minor change to 'vanilla' mustache syntax.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivecampaign%2Fmustachio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factivecampaign%2Fmustachio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factivecampaign%2Fmustachio/lists"}