0001 class BlockContext{ 0002 class var contextKey
Inheritence.swift:76 let blockContext = BlockContext(blocks: blocks)Inheritence.swift:77 context.push([BlockContext.contextKey: blockContext])Inheritence.swift:108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) {Inheritence.swift:108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) {: String { return "block_context" } 0003 0004 var blocks
Inheritence.swift:77 context.push([BlockContext.contextKey: blockContext])Inheritence.swift:108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) {: [String:BlockNode] 0005 0006 init
Inheritence.swift:7 self.blocks = blocksInheritence.swift:11 return blocks.removeValueForKey(blockName)(blocks: [String:BlockNode]) { 0007 self.blocks = blocks 0008 } 0009 0010 func pop
Inheritence.swift:76 let blockContext = BlockContext(blocks: blocks)(blockName: String) -> BlockNode? { 0011 return blocks.removeValueForKey(blockName) 0012 } 0013 } 0014 0015 0016 extension CollectionType { 0017 func any
Inheritence.swift:108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) {(closure: Generator.Element -> Bool) -> Generator.Element? { 0018 for element in self { 0019 if closure(element) { 0020 return element 0021 } 0022 } 0023 0024 return nil 0025 } 0026 } 0027 0028 0029 class ExtendsNode
Inheritence.swift:41 guard (parsedNodes.any { $0 is ExtendsNode }) == nil else {: NodeType { 0030 let templateName
Inheritence.swift:41 guard (parsedNodes.any { $0 is ExtendsNode }) == nil else {Inheritence.swift:54 return ExtendsNode(templateName: Variable(bits[1]), blocks: nodes)Namespace.swift:20 registerTag("extends", parser: ExtendsNode.parse): Variable 0031 let blocks
Inheritence.swift:58 self.templateName = templateNameInheritence.swift:67 guard let templateName = try self.templateName.resolve(context) as? String else {Inheritence.swift:68 throw TemplateSyntaxError("'\(self.templateName)' could not be resolved as a string"): [String:BlockNode] 0032 0033 class func parse
Inheritence.swift:59 self.blocks = blocksInheritence.swift:76 let blockContext = BlockContext(blocks: blocks)(parser: TokenParser, token: Token) throws -> NodeType { 0034 let bits = token.components() 0035 0036 guard bits.count == 2 else { 0037 throw TemplateSyntaxError("'extends' takes one argument, the template file to be extended") 0038 } 0039 0040 let parsedNodes = try parser.parse() 0041 guard (parsedNodes.any { $0 is ExtendsNode }) == nil else { 0042 throw TemplateSyntaxError("'extends' cannot appear more than once in the same template") 0043 } 0044 0045 let blockNodes = parsedNodes.filter { node in node is BlockNode } 0046 0047 let nodes = blockNodes.reduce([String:BlockNode]()) { (accumulator, node:NodeType) -> [String:BlockNode] in 0048 let node = (node as! BlockNode) 0049 var dict = accumulator 0050 dict[node.name] = node 0051 return dict 0052 } 0053 0054 return ExtendsNode(templateName: Variable(bits[1]), blocks: nodes) 0055 } 0056 0057 init
Namespace.swift:20 registerTag("extends", parser: ExtendsNode.parse)(templateName: Variable, blocks: [String: BlockNode]) { 0058 self.templateName = templateName 0059 self.blocks = blocks 0060 } 0061 0062 func render(context: Context) throws -> String { 0063 guard let loader = context["loader"] as? TemplateLoader else { 0064 throw TemplateSyntaxError("Template loader not in context") 0065 } 0066 0067 guard let templateName = try self.templateName.resolve(context) as? String else { 0068 throw TemplateSyntaxError("'\(self.templateName)' could not be resolved as a string") 0069 } 0070 0071 guard let template = loader.loadTemplate(templateName) else { 0072 let paths:String = loader.paths.map { $0.description }.joinWithSeparator(", ") 0073 throw TemplateSyntaxError("'\(templateName)' template not found in \(paths)") 0074 } 0075 0076 let blockContext = BlockContext(blocks: blocks) 0077 context.push([BlockContext.contextKey: blockContext]) 0078 let result = try template.render(context) 0079 context.pop() 0080 return result 0081 } 0082 } 0083 0084 0085 class BlockNode
Inheritence.swift:54 return ExtendsNode(templateName: Variable(bits[1]), blocks: nodes): NodeType { 0086 let name
Inheritence.swift:4 var blocks: [String:BlockNode]Inheritence.swift:6 init(blocks: [String:BlockNode]) {Inheritence.swift:10 func pop(blockName: String) -> BlockNode? {Inheritence.swift:31 let blocks: [String:BlockNode]Inheritence.swift:45 let blockNodes = parsedNodes.filter { node in node is BlockNode }Inheritence.swift:47 let nodes = blockNodes.reduce([String:BlockNode]()) { (accumulator, node:NodeType) -> [String:BlockNode] inInheritence.swift:47 let nodes = blockNodes.reduce([String:BlockNode]()) { (accumulator, node:NodeType) -> [String:BlockNode] inInheritence.swift:48 let node = (node as! BlockNode)Inheritence.swift:57 init(templateName: Variable, blocks: [String: BlockNode]) {Inheritence.swift:99 return BlockNode(name:blockName, nodes:nodes)Namespace.swift:21 registerTag("block", parser: BlockNode.parse): String 0087 let nodes
Inheritence.swift:50 dict[node.name] = nodeInheritence.swift:103 self.name = nameInheritence.swift:108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) {: [NodeType] 0088 0089 class func parse
Inheritence.swift:104 self.nodes = nodesInheritence.swift:112 return try renderNodes(nodes, context)(parser: TokenParser, token: Token) throws -> NodeType { 0090 let bits = token.components() 0091 0092 guard bits.count == 2 else { 0093 throw TemplateSyntaxError("'block' tag takes one argument, the template file to be included") 0094 } 0095 0096 let blockName = bits[1] 0097 let nodes = try parser.parse(until(["endblock"])) 0098 parser.nextToken() 0099 return BlockNode(name:blockName, nodes:nodes) 0100 } 0101 0102 init
Namespace.swift:21 registerTag("block", parser: BlockNode.parse)(name: String, nodes: [NodeType]) { 0103 self.name = name 0104 self.nodes = nodes 0105 } 0106 0107 func render
Inheritence.swift:99 return BlockNode(name:blockName, nodes:nodes)(context: Context) throws -> String { 0108 if let blockContext = context[BlockContext.contextKey] as? BlockContext, node = blockContext.pop(name) { 0109 return try node.render(context) 0110 } 0111 0112 return try renderNodes(nodes, context) 0113 } 0114 } 0115
Inheritence.swift:109 return try node.render(context)