Skip to content

Commit

Permalink
More security guards :-P
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSoftware committed Oct 18, 2015
1 parent 88aa28b commit b06d3e5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Stencil/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,14 @@ public class ForNode : NodeType {
}
parser.eatNextCRLF() // if CRLF after {% endfor %}, eat it

return ForNode(variable: variable, loopVariable: loopVariable, nodes: forNodes, emptyNodes:emptyNodes)
return ForNode(variable: variable, loopVariable: loopVariable, nodes: forNodes, emptyNodes: emptyNodes)
}

public init(variable:String, loopVariable:String, nodes:[NodeType], emptyNodes:[NodeType]) {
self.variable = Variable(variable)
self.loopVariable = loopVariable
self.nodes = nodes
// TODO: Handle emptyNodes
}

public func render(context: Context) throws -> String {
Expand All @@ -171,7 +172,11 @@ public class IfNode : NodeType {
public let falseNodes:[NodeType]

public class func parse(parser:TokenParser, token:Token) throws -> NodeType {
let variable = token.components()[1]
let components = token.components()
guard components.count == 2 else {
throw TemplateSyntaxError("'if' statements should use the following 'if condition' `\(token.contents)`.")
}
let variable = components[1]
var trueNodes = [NodeType]()
var falseNodes = [NodeType]()

Expand All @@ -193,7 +198,11 @@ public class IfNode : NodeType {
}

public class func parse_ifnot(parser:TokenParser, token:Token) throws -> NodeType {
let variable = token.components()[1]
let components = token.components()
guard components.count == 2 else {
throw TemplateSyntaxError("'ifnot' statements should use the following 'if condition' `\(token.contents)`.")
}
let variable = components[1]
var trueNodes = [NodeType]()
var falseNodes = [NodeType]()

Expand Down

0 comments on commit b06d3e5

Please sign in to comment.