1.3 KiB
1.3 KiB
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.
Usage
Load your templates from the filesystem
let library = HBMustacheLibrary("folder/my/templates/are/in")
This will look for all the files with the extension ".mustache" in the specified folder and sub-folders and attempt to load them.
Render an object with a template
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
let object = ["name": "John Smith", "age": 68]
let output = library.render(object, withTemplate: "myTemplate")
and
struct Person {
let name: String
let age: Int
}
let object = Person(name: "John Smith", age: 68)
let output = library.render(object, withTemplate: "myTemplate")
Support
HummingbirdMustache supports all standard Mustache tags and is fully compliant with the Mustache spec with the exception of the Lambda support.