Load templates and render objects
This commit is contained in:
26
Sources/HummingbirdMustache/Template.swift
Normal file
26
Sources/HummingbirdMustache/Template.swift
Normal 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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user