{"id":15038650,"url":"https://github.com/alwaysrightinstitute/mustache","last_synced_at":"2025-04-09T23:52:44.596Z","repository":{"id":63903057,"uuid":"84218046","full_name":"AlwaysRightInstitute/Mustache","owner":"AlwaysRightInstitute","description":"A simple Mustache parser/evaluator for Swift","archived":false,"fork":false,"pushed_at":"2024-10-09T17:50:44.000Z","size":167,"stargazers_count":24,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-09T23:52:38.707Z","etag":null,"topics":["mustache","swift","swift-library","swift3"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlwaysRightInstitute.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-03-07T15:54:47.000Z","updated_at":"2025-04-09T07:49:46.000Z","dependencies_parsed_at":"2024-11-23T21:00:38.550Z","dependency_job_id":null,"html_url":"https://github.com/AlwaysRightInstitute/Mustache","commit_stats":{"total_commits":80,"total_committers":3,"mean_commits":"26.666666666666668","dds":0.2875,"last_synced_commit":"e0654482a34a5610724a0e5451507c04712adcff"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlwaysRightInstitute%2FMustache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlwaysRightInstitute%2FMustache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlwaysRightInstitute%2FMustache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlwaysRightInstitute%2FMustache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlwaysRightInstitute","download_url":"https://codeload.github.com/AlwaysRightInstitute/Mustache/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131454,"owners_count":21052819,"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":["mustache","swift","swift-library","swift3"],"created_at":"2024-09-24T20:39:30.006Z","updated_at":"2025-04-09T23:52:44.567Z","avatar_url":"https://github.com/AlwaysRightInstitute.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mustache\n\n![Swift4](https://img.shields.io/badge/swift-4-blue.svg)\n![Swift5](https://img.shields.io/badge/swift-5-blue.svg)\n![macOS](https://img.shields.io/badge/os-macOS-green.svg?style=flat)\n![tuxOS](https://img.shields.io/badge/os-tuxOS-green.svg?style=flat)\n[![Build and Test](https://github.com/AlwaysRightInstitute/Mustache/actions/workflows/swift.yml/badge.svg?branch=main)](https://github.com/AlwaysRightInstitute/Mustache/actions/workflows/swift.yml)\n\nA simple [Mustache](http://mustache.github.io) parser/evaluator for Swift.\n\n[Mustache](http://mustache.github.io) is a very simple templating language.\nImplementations are available for pretty much any programming language\n(check the [Mustache](http://mustache.github.io) website) - this is one for\nSwift.\n\nIn the context of Noze.io you don't need to call this manually,\nbut you can just use the Mustache template support in the\nNoze.io [Express](../express) module.\nCheckout the [express-simple](../../Samples/express-simple) app as an example\non how to do this.\n\nThis Mustache implementation comes with a very simple Key-Value coding\nimplementation, which is used to extract values from model objects for\nrendering.\nWith that you can render both, generic Dictionary/Array structures as well\nas Swift objects with properties.\nSince the reflection capabilities of Swift are pretty limited, so is the\nKVC implementation.\n\n## Example\n\nSample Mustache:\n\n    Hello {{name}}\n    You have just won {{\u0026 value}} dollars!\n    {{#in_ca}}\n      Well, {{{taxed_value}}} dollars, after taxes.\n    {{/in_ca}}\n    {{#addresses}}\n      Has address in: {{city}}\n    {{/addresses}}\n    {{^addresses}}\n      Has NO addresses\n    {{/addresses}}\n\nThe template features value access: `{{name}}`,\nconditionals: `{{#in_ca}}`,\nas well as repetitions: `{{#addresses}}`.\n\nSample code to parse and evaluate the template:\n\n    let sampleDict  : [ String : Any ] = [\n      \"name\"        : \"Chris\",\n      \"value\"       : 10000,\n      \"taxed_value\" : Int(10000 - (10000 * 0.4)),\n      \"in_ca\"       : true,\n      \"addresses\"   : [\n        [ \"city\"    : \"Cupertino\" ]\n      ]\n    ]\n    \n    var parser = MustacheParser()\n    let tree   = parser.parse(string: template)\n    let result = tree.render(object: sampleDict)\n\nYou get the idea.\n\n## Swift 5 Dynamic Callable\n\nIn Swift 5 you can expose Mustache templates as regular Swift functions.\n\nTo declare a Mustache backed function:\n\n```swift\nlet generateHTMLForWinner = Mustache(\n    \"\"\"\n    {% raw %}Hello {{name}}\n    You have just won {{\u0026 value}} dollars!\n    {{#in_ca}}\n        Well, {{{taxed_value}}} dollars, after taxes.\n    {{/in_ca}}\n    {{#addresses}}\n        Has address in: {{city}}\n    {{/addresses}}\n    {{^addresses}}\n        Has NO addresses\n    {{/addresses}}{% endraw %}\n    \"\"\"\n)\n```\n\nTo call the function:\n\n```swift\nlet winners = [\n    generateHTMLForWinner(\n        name: \"Chris\", value: 10000,\n        taxed_value: 6000, in_ca: true,\n        addresses: [[ \"city\": \"Cupertino\" ]]\n    ),\n    generateHTMLForWinner(\n        name: \"Michael\", value: 6000,\n        taxed_value: 6000, in_ca: false,\n        addresses: [[ \"city\": \"Austin\" ]]\n    )\n]\n```\n\nCheckout our [blog](http://www.alwaysrightinstitute.com/mustachable/)\nfor more info on this.\n\n\n### Who\n\n**mustache** is brought to you by\n[The Always Right Institute](http://www.alwaysrightinstitute.com)\nand\n[ZeeZide](http://zeezide.de).\nWe like feedback, GitHub stars, cool contract work,\npresumably any form of praise you can think of.\nWe don't like people who are wrong.\n\nAsk questions on the [Noze.io Slack](http://slack.noze.io).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysrightinstitute%2Fmustache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falwaysrightinstitute%2Fmustache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falwaysrightinstitute%2Fmustache/lists"}