This commit is contained in:
Adam Fowler
2021-03-15 15:09:16 +00:00
parent 978b14a96a
commit e391f5ae05
8 changed files with 70 additions and 27 deletions

View File

@@ -1,17 +1,23 @@
/// Class holding Mustache template
public class HBMustacheTemplate {
/// Initialize template
/// - Parameter string: Template text
/// - Throws: HBMustacheTemplate.Error
public init(string: String) throws {
self.tokens = try Self.parse(string)
}
internal init(_ tokens: [Token]) {
self.tokens = tokens
}
/// Render object using this template
/// - Parameter object: Object to render
/// - Returns: Rendered text
public func render(_ object: Any) -> String {
self.render(object, context: nil)
}
internal init(_ tokens: [Token]) {
self.tokens = tokens
}
internal func setLibrary(_ library: HBMustacheLibrary) {
self.library = library
for token in tokens {