Template inheritance (#9)

* Move all context variables into HBMustacheContext

* Add support for reading inherited sections

* Render inherited tokens

* Test inheritance spec, fix two minor issues

* fix warning

* swift format
This commit is contained in:
Adam Fowler
2021-03-22 12:02:22 +00:00
committed by GitHub
parent af345e9138
commit 35d52603e2
9 changed files with 232 additions and 59 deletions

View File

@@ -30,6 +30,16 @@ public final class HBMustacheLibrary {
self.templates[name] = template
}
/// Register template under name
/// - Parameters:
/// - mustache: Mustache text
/// - name: Name of template
public func register(_ mustache: String, named name: String) throws {
let template = try HBMustacheTemplate(string: mustache)
template.setLibrary(self)
self.templates[name] = template
}
/// Return template registed with name
/// - Parameter name: name to search for
/// - Returns: Template