From 876f3c99f53f74c6bdebebe05b1c6dd59c9a0695 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Mon, 15 Mar 2021 15:24:03 +0000 Subject: [PATCH] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcbc7e5..266f871 100644 --- a/README.md +++ b/README.md @@ -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.