All Projects → AlwaysRightInstitute → Mustache

AlwaysRightInstitute / Mustache

Licence: apache-2.0
A simple Mustache parser/evaluator for Swift

Programming Languages

swift
15916 projects
swift3
66 projects

Labels

Projects that are alternatives of or similar to Mustache

moustachu
Mustache templating for Nim
Stars: ✭ 58 (+190%)
Mutual labels:  mustache
Universe
The Mesosphere Universe package repository.
Stars: ✭ 308 (+1440%)
Mutual labels:  mustache
Grmustache.swift
Flexible Mustache templates for Swift
Stars: ✭ 538 (+2590%)
Mutual labels:  mustache
laravel-mjml
Laravel MJML offers support for rendering MJML syntax into in-line HTML that can be sent within mails.
Stars: ✭ 26 (+30%)
Mutual labels:  mustache
Handlebars
Fullest Handlebars.js templating support for Atom and Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://atom.io/packages/Handlebars and https://packagecontrol.io/packages/Handlebars.
Stars: ✭ 292 (+1360%)
Mutual labels:  mustache
Mikado
Mikado is the webs fastest template library for building user interfaces.
Stars: ✭ 323 (+1515%)
Mutual labels:  mustache
docxmustache
laravel 8.x docx template manipulation class, based on mustache templating language
Stars: ✭ 34 (+70%)
Mutual labels:  mustache
Harbor Helm
The helm chart to deploy Harbor
Stars: ✭ 647 (+3135%)
Mutual labels:  mustache
Helm Charts
A curated set of Helm charts brought to you by codecentric
Stars: ✭ 295 (+1375%)
Mutual labels:  mustache
Eks Charts
Amazon EKS Helm chart repository
Stars: ✭ 428 (+2040%)
Mutual labels:  mustache
Argo Helm
ArgoProj Helm Charts
Stars: ✭ 263 (+1215%)
Mutual labels:  mustache
Charts
Easily deploy Sentry on your Kubernetes Cluster
Stars: ✭ 277 (+1285%)
Mutual labels:  mustache
Client
The Hypothesis web-based annotation client.
Stars: ✭ 416 (+1980%)
Mutual labels:  mustache
twitch-chat-visualizer
A Node.js Project. Would you like to see your chat stream with a custom design? This is for you!
Stars: ✭ 14 (-30%)
Mutual labels:  mustache
Lightncandy
An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ),
Stars: ✭ 565 (+2725%)
Mutual labels:  mustache
sawmill
Sawmill is a JSON transformation Java library
Stars: ✭ 92 (+360%)
Mutual labels:  mustache
Banzai Charts
Curated list of Banzai Cloud Helm charts used by the Pipeline Platform
Stars: ✭ 312 (+1460%)
Mutual labels:  mustache
Handlebars.net
A real .NET Handlebars engine
Stars: ✭ 723 (+3515%)
Mutual labels:  mustache
Mormot
Synopse mORMot ORM/SOA/MVC framework
Stars: ✭ 607 (+2935%)
Mutual labels:  mustache
Charts
Helm charts for applications you run at home
Stars: ✭ 421 (+2005%)
Mutual labels:  mustache

Mustache

Swift3 Swift4 Swift5 macOS tuxOS Travis

A simple Mustache parser/evaluator for Swift.

Mustache is a very simple templating language. Implementations are available for pretty much any programming language (check the Mustache website) - this is one for Swift.

In the context of Noze.io you don't need to call this manually, but you can just use the Mustache template support in the Noze.io Express module. Checkout the express-simple app as an example on how to do this.

This Mustache implementation comes with a very simple Key-Value coding implementation, which is used to extract values from model objects for rendering. With that you can render both, generic Dictionary/Array structures as well as Swift objects with properties. Since the reflection capabilities of Swift are pretty limited, so is the KVC implementation.

Example

Sample Mustache:

Hello {{name}}
You have just won {{& value}} dollars!
{{#in_ca}}
  Well, {{{taxed_value}}} dollars, after taxes.
{{/in_ca}}
{{#addresses}}
  Has address in: {{city}}
{{/addresses}}
{{^addresses}}
  Has NO addresses
{{/addresses}}

The template features value access: {{name}}, conditionals: {{#in_ca}}, as well as repetitions: {{#addresses}}.

Sample code to parse and evaluate the template:

let sampleDict  : [ String : Any ] = [
  "name"        : "Chris",
  "value"       : 10000,
  "taxed_value" : Int(10000 - (10000 * 0.4)),
  "in_ca"       : true,
  "addresses"   : [
    [ "city"    : "Cupertino" ]
  ]
]

let parser = MustacheParser()
let tree   = parser.parse(string: template)
let result = tree.render(object: sampleDict)

You get the idea.

Swift 5 Dynamic Callable

In Swift 5 you can expose Mustache templates as regular Swift functions.

To declare a Mustache backed function:

let generateHTMLForWinner = Mustache(
      """
      {% raw %}Hello {{name}}
      You have just won {{& value}} dollars!
      {{#in_ca}}
        Well, {{{taxed_value}}} dollars, after taxes.
      {{/in_ca}}
      {{#addresses}}
        Has address in: {{city}}
      {{/addresses}}
      {{^addresses}}
        Has NO addresses
      {{/addresses}}{% endraw %}
      """)

To call the function:

let winners = [
      generateHTMLForWinner(
        name: "Chris", value: 10000,
        taxed_value: 6000, in_ca: true,
        addresses: [[ "city": "Cupertino" ]]
      ),
      generateHTMLForWinner(
        name: "Michael", value: 6000,
        taxed_value: 6000, in_ca: false,
        addresses: [[ "city": "Austin" ]]
      )
    ]

Checkout our blog for more info on this.

Who

mustache is brought to you by The Always Right Institute and ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of. We don't like people who are wrong.

Ask questions on the Noze.io Slack.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].