Restore code style
This commit is contained in:
@@ -126,23 +126,23 @@ public class ForNode : NodeType {
|
||||
guard components.count == 4 && components[2] == "in" else {
|
||||
throw TemplateSyntaxError("'for' statements should use the following 'for x in y' `\(token.contents)`.")
|
||||
}
|
||||
|
||||
|
||||
let loopVariable = components[1]
|
||||
let variable = components[3]
|
||||
|
||||
|
||||
var emptyNodes = [NodeType]()
|
||||
|
||||
|
||||
let forNodes = try parser.parse(until(["endfor", "empty"]))
|
||||
|
||||
|
||||
guard let token = parser.nextToken() else {
|
||||
throw TemplateSyntaxError("`endfor` was not found.")
|
||||
}
|
||||
|
||||
|
||||
if token.contents == "empty" {
|
||||
emptyNodes = try parser.parse(until(["endfor"]))
|
||||
parser.nextToken()
|
||||
}
|
||||
|
||||
|
||||
return ForNode(variable: variable, loopVariable: loopVariable, nodes: forNodes, emptyNodes:emptyNodes)
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class IfNode : NodeType {
|
||||
guard let token = parser.nextToken() else {
|
||||
throw TemplateSyntaxError("`endif` was not found.")
|
||||
}
|
||||
|
||||
|
||||
if token.contents == "else" {
|
||||
falseNodes = try parser.parse(until(["endif"]))
|
||||
parser.nextToken()
|
||||
@@ -211,7 +211,7 @@ public class IfNode : NodeType {
|
||||
guard let token = parser.nextToken() else {
|
||||
throw TemplateSyntaxError("`endif` was not found.")
|
||||
}
|
||||
|
||||
|
||||
if token.contents == "else" {
|
||||
trueNodes = try parser.parse(until(["endif"]))
|
||||
parser.nextToken()
|
||||
|
||||
@@ -70,8 +70,8 @@ public class TokenParser {
|
||||
let tag = token.components().first
|
||||
|
||||
if let parse_until = parse_until where parse_until(parser: self, token: token) {
|
||||
prependToken(token)
|
||||
return nodes
|
||||
prependToken(token)
|
||||
return nodes
|
||||
}
|
||||
|
||||
if let tag = tag {
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Template {
|
||||
guard let url = useBundle.URLForResource(named, withExtension: nil) else {
|
||||
throw NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError, userInfo: nil)
|
||||
}
|
||||
|
||||
|
||||
try self.init(URL:url)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Template {
|
||||
if nodes == nil {
|
||||
nodes = try parser.parse()
|
||||
}
|
||||
|
||||
|
||||
return try renderNodes(nodes!, context ?? Context())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ public class IncludeNode : NodeType {
|
||||
}
|
||||
|
||||
guard let template = loader.loadTemplate(templateName) else {
|
||||
let paths:String = loader.paths.map { $0.description }.joinWithSeparator(", ")
|
||||
let paths = loader.paths.map { $0.description }.joinWithSeparator(", ")
|
||||
throw TemplateSyntaxError("'\(templateName)' template not found in \(paths)")
|
||||
}
|
||||
|
||||
|
||||
return try template.render(context)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class ExtendsNode : NodeType {
|
||||
guard let loader = context["loader"] as? TemplateLoader else {
|
||||
throw TemplateSyntaxError("Template loader not in context")
|
||||
}
|
||||
|
||||
|
||||
guard let template = loader.loadTemplate(templateName) else {
|
||||
let paths:String = loader.paths.map { $0.description }.joinWithSeparator(", ")
|
||||
throw TemplateSyntaxError("'\(templateName)' template not found in \(paths)")
|
||||
|
||||
Reference in New Issue
Block a user