removed whitespace changes
This commit is contained in:
@@ -37,8 +37,6 @@ public struct TemplateSyntaxError : Error, Equatable, CustomStringConvertible {
|
|||||||
public init(_ description: String) {
|
public init(_ description: String) {
|
||||||
self.init(reason: description)
|
self.init(reason: description)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Error {
|
extension Error {
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ class ExtendsNode : NodeType {
|
|||||||
guard (parsedNodes.any { $0 is ExtendsNode }) == nil else {
|
guard (parsedNodes.any { $0 is ExtendsNode }) == nil else {
|
||||||
throw TemplateSyntaxError("'extends' cannot appear more than once in the same template")
|
throw TemplateSyntaxError("'extends' cannot appear more than once in the same template")
|
||||||
}
|
}
|
||||||
|
|
||||||
let blockNodes = parsedNodes.compactMap { $0 as? BlockNode }
|
let blockNodes = parsedNodes.compactMap { $0 as? BlockNode }
|
||||||
|
|
||||||
let nodes = blockNodes.reduce([String: BlockNode]()) { (accumulator, node) -> [String: BlockNode] in
|
let nodes = blockNodes.reduce([String: BlockNode]()) { (accumulator, node) -> [String: BlockNode] in
|
||||||
var dict = accumulator
|
var dict = accumulator
|
||||||
dict[node.name] = node
|
dict[node.name] = node
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ struct Lexer {
|
|||||||
init(templateName: String? = nil, templateString: String) {
|
init(templateName: String? = nil, templateString: String) {
|
||||||
self.templateName = templateName
|
self.templateName = templateName
|
||||||
self.templateString = templateString
|
self.templateString = templateString
|
||||||
|
|
||||||
self.lines = templateString.components(separatedBy: .newlines).enumerated().compactMap {
|
self.lines = templateString.components(separatedBy: .newlines).enumerated().compactMap {
|
||||||
guard !$0.element.isEmpty else { return nil }
|
guard !$0.element.isEmpty else { return nil }
|
||||||
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
|
return (content: $0.element, number: UInt($0.offset + 1), templateString.range(of: $0.element)!)
|
||||||
|
|||||||
@@ -116,13 +116,12 @@ public struct Variable : Equatable, Resolvable {
|
|||||||
|
|
||||||
return normalize(current)
|
return normalize(current)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func resolveCollection<T: Collection>(_ collection: T, bit: String) -> Any? {
|
private func resolveCollection<T: Collection>(_ collection: T, bit: String) -> Any? {
|
||||||
if let index = Int(bit) {
|
if let index = Int(bit) {
|
||||||
if index >= 0 && index < collection.count {
|
if index >= 0 && index < collection.count {
|
||||||
return collection[collection.index(collection.startIndex, offsetBy: index)]
|
return collection[collection.index(collection.startIndex, offsetBy: index)]
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user