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

@@ -53,7 +53,7 @@ class ExtendsNode : NodeType {
let token: Token?
class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {
let bits = token.components()
let bits = token.components
guard bits.count == 2 else {
throw TemplateSyntaxError("'extends' takes one argument, the template file to be extended")
@@ -124,7 +124,7 @@ class BlockNode : NodeType {
let token: Token?
class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {
let bits = token.components()
let bits = token.components
guard bits.count == 2 else {
throw TemplateSyntaxError("'block' tag takes one argument, the block name")
@@ -163,7 +163,7 @@ class BlockNode : NodeType {
var childContext: [String: Any] = [BlockContext.contextKey: blockContext]
if let blockSuperNode = child.nodes.first(where: {
if case .variable(let variable, _)? = $0.token, variable == "block.super" { return true }
if let token = $0.token, case .variable = token.kind, token.contents == "block.super" { return true }
else { return false}
}) {
do {