fixed indetnations
This commit is contained in:
@@ -189,8 +189,7 @@ extension String {
|
|||||||
lineNumber += 1
|
lineNumber += 1
|
||||||
lineContent = line
|
lineContent = line
|
||||||
if let rangeOfLine = self.range(of: line), rangeOfLine.contains(range.lowerBound) {
|
if let rangeOfLine = self.range(of: line), rangeOfLine.contains(range.lowerBound) {
|
||||||
offset = distance(from: rangeOfLine.lowerBound, to:
|
offset = distance(from: rangeOfLine.lowerBound, to: range.lowerBound)
|
||||||
range.lowerBound)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ public protocol NodeType {
|
|||||||
|
|
||||||
/// Render the collection of nodes in the given context
|
/// Render the collection of nodes in the given context
|
||||||
public func renderNodes(_ nodes:[NodeType], _ context:Context) throws -> String {
|
public func renderNodes(_ nodes:[NodeType], _ context:Context) throws -> String {
|
||||||
return try nodes.map({
|
return try nodes.map {
|
||||||
do {
|
do {
|
||||||
return try $0.render(context)
|
return try $0.render(context)
|
||||||
} catch {
|
} catch {
|
||||||
throw error.withToken($0.token)
|
throw error.withToken($0.token)
|
||||||
}
|
}
|
||||||
}).joined(separator: "")
|
}.joined(separator: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleNode : NodeType {
|
public class SimpleNode : NodeType {
|
||||||
|
|||||||
@@ -120,19 +120,18 @@ public class TokenParser {
|
|||||||
do {
|
do {
|
||||||
return try FilterExpression(token: filterToken, parser: self)
|
return try FilterExpression(token: filterToken, parser: self)
|
||||||
} catch {
|
} catch {
|
||||||
if var error = error as? TemplateSyntaxError, error.token == nil {
|
guard var syntaxError = error as? TemplateSyntaxError, syntaxError.token == nil else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
// find offset of filter in the containing token so that only filter is highligted, not the whole token
|
// find offset of filter in the containing token so that only filter is highligted, not the whole token
|
||||||
if let filterTokenRange = containingToken.contents.range(of: filterToken) {
|
if let filterTokenRange = containingToken.contents.range(of: filterToken) {
|
||||||
var rangeLine = containingToken.sourceMap.line
|
var rangeLine = containingToken.sourceMap.line
|
||||||
rangeLine.offset += containingToken.contents.distance(from: containingToken.contents.startIndex, to: filterTokenRange.lowerBound)
|
rangeLine.offset += containingToken.contents.distance(from: containingToken.contents.startIndex, to: filterTokenRange.lowerBound)
|
||||||
error.token = .variable(value: filterToken, at: SourceMap(filename: containingToken.sourceMap.filename, line: rangeLine))
|
syntaxError.token = .variable(value: filterToken, at: SourceMap(filename: containingToken.sourceMap.filename, line: rangeLine))
|
||||||
} else {
|
} else {
|
||||||
error.token = containingToken
|
syntaxError.token = containingToken
|
||||||
}
|
|
||||||
throw error
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
|
throw syntaxError
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user