https://github.com/hummingbird-project/swift-mustache
Mustache templating engine
https://github.com/hummingbird-project/swift-mustache
hummingbird mustache swift
Last synced: 2 months ago
JSON representation
Mustache templating engine
- Host: GitHub
- URL: https://github.com/hummingbird-project/swift-mustache
- Owner: hummingbird-project
- License: apache-2.0
- Created: 2021-03-11T13:57:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-06-23T11:27:57.000Z (4 months ago)
- Last Synced: 2025-07-28T17:12:42.552Z (2 months ago)
- Topics: hummingbird, mustache, swift
- Language: Swift
- Homepage:
- Size: 247 KB
- Stars: 59
- Watchers: 2
- Forks: 4
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Swift-Mustache
Package for rendering Mustache templates. Mustache is a "logic-less" templating language commonly used in web and mobile platforms. You can find out more about Mustache [here](http://mustache.github.io/mustache.5.html).
## Usage
Load your templates from the filesystem
```swift
import Mustache
let library = MustacheLibrary("folder/my/templates/are/in")
```
This will look for all the files with the extension ".mustache" in the specified folder and subfolders and attempt to load them. Each file is registed with the name of the file (with subfolder, if inside a subfolder) minus the "mustache" extension.Render an object with a template
```swift
let output = library.render(object, withTemplate: "myTemplate")
```
`Swift-Mustache` treats an object as a set of key/value pairs when rendering and will render both dictionaries and objects via `Mirror` reflection. Find out more on how Mustache renders objects [here](https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachesyntax).## Support
Swift-Mustache supports all standard Mustache tags and is fully compliant with the Mustache [spec](https://github.com/mustache/spec) with the exception of the Lambda support.
## Additional features
Swift-Mustache includes some features that are specific to its implementation. Please follow the links below to find out more.
- [Lambda Implementation](https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachefeatures#Lambdas)
- [Transforms](https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachefeatures#Transforms)
- [Template Inheritance](https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachefeatures#Template-inheritance-and-parents)
- [Pragmas](https://docs.hummingbird.codes/2.0/documentation/hummingbird/mustachefeatures#PragmasConfiguration-variables)## Documentation
Reference documentation for swift-mustache can be found [here](https://docs.hummingbird.codes/2.0/documentation/mustache)