Add library and support for partials

This commit is contained in:
Adam Fowler
2021-03-12 08:41:13 +00:00
parent 7f61c8dd72
commit fc53f09dfb
6 changed files with 109 additions and 41 deletions

View File

@@ -0,0 +1,17 @@
public class HBMustacheLibrary {
init() {
self.templates = [:]
}
public func register(_ template: HBMustacheTemplate, named name: String) {
templates[name] = template
}
public func render(_ object: Any, withTemplateNamed name: String) -> String? {
guard let template = templates[name] else { return nil }
return template.render(object, library: self)
}
var templates: [String: HBMustacheTemplate]
}