0001 // The MIT License 0002 // 0003 // Copyright (c) 2015 Gwendal Roué 0004 // 0005 // Permission is hereby granted, free of charge, to any person obtaining a copy 0006 // of this software and associated documentation files (the "Software"), to deal 0007 // in the Software without restriction, including without limitation the rights 0008 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 0009 // copies of the Software, and to permit persons to whom the Software is 0010 // furnished to do so, subject to the following conditions: 0011 // 0012 // The above copyright notice and this permission notice shall be included in 0013 // all copies or substantial portions of the Software. 0014 // 0015 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 0016 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 0017 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 0018 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 0019 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 0020 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 0021 // THE SOFTWARE. 0022 0023 struct ExpressionInvocation{ 0024 let expression
Context.swift:205 let invocation = ExpressionInvocation(expression: expression)RenderingEngine.swift:134 box = try ExpressionInvocation(expression: expression).invokeWithContext(context): Expression 0025 0026 func invokeWithContext
ExpressionInvocation.swift:27 return try evaluate(context: context, expression: expression)(context: Context) throws -> MustacheBox { 0027 return try evaluate(context: context, expression: expression) 0028 } 0029 0030 private func evaluate
Context.swift:206 return try invocation.invokeWithContext(self)RenderingEngine.swift:134 box = try ExpressionInvocation(expression: expression).invokeWithContext(context)(context context: Context, expression: Expression) throws -> MustacheBox { 0031 switch expression { 0032 case .ImplicitIterator: 0033 // {{ . }} 0034 0035 return context.topBox 0036 0037 case .Identifier(let identifier): 0038 // {{ identifier }} 0039 0040 return context.mustacheBoxForKey(identifier) 0041 0042 case .Scoped(let baseExpression, let identifier): 0043 // {{ <expression>.identifier }} 0044 0045 return try evaluate(context: context, expression: baseExpression).mustacheBoxForKey(identifier) 0046 0047 case .Filter(let filterExpression, let argumentExpression, let partialApplication): 0048 // {{ <expression>(<expression>) }} 0049 0050 let filterBox = try evaluate(context: context, expression: filterExpression) 0051 0052 guard let filter = filterBox.filter else { 0053 if filterBox.isEmpty { 0054 throw MustacheError(kind: .RenderError, message: "Missing filter") 0055 } else { 0056 throw MustacheError(kind: .RenderError, message: "Not a filter") 0057 } 0058 } 0059 0060 let argumentBox = try evaluate(context: context, expression: argumentExpression) 0061 return try filter(box: argumentBox, partialApplication: partialApplication) 0062 } 0063 } 0064 } 0065
ExpressionInvocation.swift:27 return try evaluate(context: context, expression: expression)ExpressionInvocation.swift:45 return try evaluate(context: context, expression: baseExpression).mustacheBoxForKey(identifier)ExpressionInvocation.swift:50 let filterBox = try evaluate(context: context, expression: filterExpression)ExpressionInvocation.swift:60 let argumentBox = try evaluate(context: context, expression: argumentExpression)