Convert Token from enum to struct (#256)

* convert Token from enum to struct

* private setter for components

* updated CHANGELOG
This commit is contained in:
Ilya Puchka
2018-09-30 21:48:44 +01:00
committed by GitHub
parent 9a6ba94d7d
commit d9f6a82f97
11 changed files with 62 additions and 54 deletions

View File

@@ -240,7 +240,7 @@ class IfNode : NodeType {
let token: Token?
class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {
var components = token.components()
var components = token.components
components.removeFirst()
let expression = try parseExpression(components: components, tokenParser: parser, token: token)
@@ -251,7 +251,7 @@ class IfNode : NodeType {
var nextToken = parser.nextToken()
while let current = nextToken, current.contents.hasPrefix("elif") {
var components = current.components()
var components = current.components
components.removeFirst()
let expression = try parseExpression(components: components, tokenParser: parser, token: current)
@@ -273,7 +273,7 @@ class IfNode : NodeType {
}
class func parse_ifnot(_ parser: TokenParser, token: Token) throws -> NodeType {
var components = token.components()
var components = token.components
guard components.count == 2 else {
throw TemplateSyntaxError("'ifnot' statements should use the following syntax 'ifnot condition'.")
}