refactor: TemplateLoader to protocol, follow Swift API guidelines
This commit is contained in:
@@ -9,6 +9,12 @@ let NSFileNoSuchFileError = 4
|
||||
public class Template: ExpressibleByStringLiteral {
|
||||
let tokens: [Token]
|
||||
|
||||
/// Create a template with a template string
|
||||
public init(templateString: String) {
|
||||
let lexer = Lexer(templateString: templateString)
|
||||
tokens = lexer.tokenize()
|
||||
}
|
||||
|
||||
/// Create a template with the given name inside the given bundle
|
||||
public convenience init(named:String, inBundle bundle:Bundle? = nil) throws {
|
||||
let useBundle = bundle ?? Bundle.main
|
||||
@@ -25,28 +31,22 @@ public class Template: ExpressibleByStringLiteral {
|
||||
}
|
||||
|
||||
/// Create a template with a file found at the given path
|
||||
public convenience init(path:Path) throws {
|
||||
public convenience init(path: Path) throws {
|
||||
self.init(templateString: try path.read())
|
||||
}
|
||||
|
||||
/// Create a template with a template string
|
||||
public init(templateString:String) {
|
||||
let lexer = Lexer(templateString: templateString)
|
||||
tokens = lexer.tokenize()
|
||||
}
|
||||
|
||||
// Create a template with a template string literal
|
||||
public convenience required init(stringLiteral value:String) {
|
||||
public convenience required init(stringLiteral value: String) {
|
||||
self.init(templateString: value)
|
||||
}
|
||||
|
||||
// Create a template with a template string literal
|
||||
public convenience required init(extendedGraphemeClusterLiteral value:StringLiteralType) {
|
||||
public convenience required init(extendedGraphemeClusterLiteral value: StringLiteralType) {
|
||||
self.init(stringLiteral: value)
|
||||
}
|
||||
|
||||
// Create a template with a template string literal
|
||||
public convenience required init(unicodeScalarLiteral value:StringLiteralType) {
|
||||
public convenience required init(unicodeScalarLiteral value: StringLiteralType) {
|
||||
self.init(stringLiteral: value)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user