Keep pointer to Library in template

This commit is contained in:
Adam Fowler
2021-03-14 08:51:16 +00:00
parent aaf285154d
commit 06251739d7
6 changed files with 56 additions and 34 deletions

View File

@@ -10,6 +10,7 @@ public class HBMustacheLibrary {
}
public func register(_ template: HBMustacheTemplate, named name: String) {
template.setLibrary(self)
templates[name] = template
}
@@ -19,7 +20,7 @@ public class HBMustacheLibrary {
public func render(_ object: Any, withTemplateNamed name: String) -> String? {
guard let template = templates[name] else { return nil }
return template.render(object, library: self)
return template.render(object)
}
private var templates: [String: HBMustacheTemplate]