Load templates and render objects

This commit is contained in:
Adam Fowler
2021-03-11 16:58:49 +00:00
parent 98f5d19e91
commit 9cbe74f9ee
10 changed files with 1036 additions and 98 deletions

View File

@@ -0,0 +1,26 @@
enum HBMustacheError: Error {
case sectionCloseNameIncorrect
case unfinishedSectionName
case expectedSectionEnd
}
public class HBTemplate {
public init(_ string: String) throws {
self.tokens = try Self.parse(string)
}
internal init(_ tokens: [Token]) {
self.tokens = tokens
}
enum Token {
case text(String)
case variable(String)
case section(String, HBTemplate)
case invertedSection(String, HBTemplate)
}
let tokens: [Token]
}