Files
swiftpm-mustache/Sources/HummingbirdMustache/Template.swift
2021-03-12 08:41:13 +00:00

29 lines
615 B
Swift

enum HBMustacheError: Error {
case sectionCloseNameIncorrect
case unfinishedSectionName
case expectedSectionEnd
}
public class HBMustacheTemplate {
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 unescapedVariable(String)
case section(String, HBMustacheTemplate)
case invertedSection(String, HBMustacheTemplate)
case partial(String)
}
let tokens: [Token]
}