Update README.md

This commit is contained in:
Adam Fowler
2021-03-15 15:24:03 +00:00
committed by GitHub
parent 5dd3ab2af1
commit 876f3c99f5

View File

@@ -1,3 +1,31 @@
# hummingbird-mustache
# HummingbirdMustache
Package for rendering Mustache templates. Mustache is a templating language commonly used in server frameworks for generating HTML files (although it is not limited to HTML). You can find out more about Mustache [here](http://mustache.github.io/mustache.5.html).
## Usage
Load your templates from the filesystem
```swift
let library = HBMustacheLibrary("folder/my/templates/are/in")
```
This will look for all the files with the extension ".mustache" and attempt to load them
Render an object with a template
```swift
let output = library.render(object, withTemplate: "myTemplate")
```
`HummingbirdMustache` will render both dictionaries and objects via `Mirror` reflection. The following two examples will both produce the same output
```swift
let object = ["name": "John Smith", "age": 68]
let output = library.render(object, withTemplate: "myTemplate")
```
and
```swift
struct Person {
let name: String
let age: Int
}
let object = Person(name: "John Smith", age: 68)
let output = library.render(object, withTemplate: "myTemplate")
```
A description of this package.