reporting node rendering errors using reference to node’s token

This commit is contained in:
Ilya Puchka
2017-12-23 15:19:36 +01:00
parent 27135f3ea3
commit 53c1550c5b
15 changed files with 186 additions and 47 deletions

View File

@@ -4,6 +4,7 @@ import Foundation
class NowNode : NodeType {
let format:Variable
let token: Token?
class func parse(_ parser:TokenParser, token:Token) throws -> NodeType {
var format:Variable?
@@ -16,11 +17,12 @@ class NowNode : NodeType {
format = Variable(components[1])
}
return NowNode(format:format)
return NowNode(format:format, token: token)
}
init(format:Variable?) {
init(format:Variable?, token: Token? = nil) {
self.format = format ?? Variable("\"yyyy-MM-dd 'at' HH:mm\"")
self.token = token
}
func render(_ context: Context) throws -> String {