@@ -17,7 +17,7 @@ public class TemplateLanguage: EvaluatorWithContext {
1717 return language. evaluate ( expression)
1818 }
1919
20- public func evaluate( _ expression: String , context: InterpreterContext ? = nil ) -> String {
20+ public func evaluate( _ expression: String , context: InterpreterContext ) -> String {
2121 return language. evaluate ( expression, context: context)
2222 }
2323}
@@ -353,7 +353,7 @@ public class StandardLibrary {
353353 public static func function< T> ( _ name: String , body: @escaping ( [ Any ] ) -> T ? ) -> Function < T > {
354354 return Function ( [ Keyword ( name) , OpenKeyword ( " ( " ) , Variable < String > ( " arguments " , shortest: true , interpreted: false ) , CloseKeyword ( " ) " ) ] ) { variables, interpreter, _ in
355355 guard let arguments = variables [ " arguments " ] as? String else { return nil }
356- let interpretedArguments = arguments. split ( separator: " , " ) . flatMap { interpreter. evaluate ( String ( $0) . trim ( ) ) }
356+ let interpretedArguments = arguments. split ( separator: " , " ) . flatMap { interpreter. evaluate ( String ( $0) . trimmingCharacters ( in : . whitespacesAndNewlines ) ) }
357357 return body ( interpretedArguments)
358358 }
359359 }
@@ -363,7 +363,7 @@ public class StandardLibrary {
363363 guard let arguments = variables [ " arguments " ] as? String else { return nil }
364364 var interpretedArguments : [ String : Any ] = [ : ]
365365 for argument in arguments. split ( separator: " , " ) {
366- let parts = String ( argument) . trim ( ) . split ( separator: " = " )
366+ let parts = String ( argument) . trimmingCharacters ( in : . whitespacesAndNewlines ) . split ( separator: " = " )
367367 if let key = parts. first, let value = parts. last {
368368 interpretedArguments [ String ( key) ] = interpreter. evaluate ( String ( value) )
369369 }
@@ -388,7 +388,7 @@ public class StandardLibrary {
388388 return value
389389 } , Keyword ( " ( " ) , Variable < String > ( " arguments " , interpreted: false ) , Keyword ( " ) " ) ] ) { variables, interpreter, _ in
390390 guard let object = variables [ " lhs " ] as? O , variables [ " rhs " ] != nil , let arguments = variables [ " arguments " ] as? String else { return nil }
391- let interpretedArguments = arguments. split ( separator: " , " ) . flatMap { interpreter. evaluate ( String ( $0) . trim ( ) ) }
391+ let interpretedArguments = arguments. split ( separator: " , " ) . flatMap { interpreter. evaluate ( String ( $0) . trimmingCharacters ( in : . whitespacesAndNewlines ) ) }
392392 return body ( object, interpretedArguments)
393393 }
394394 }
@@ -401,7 +401,7 @@ public class StandardLibrary {
401401 guard let object = variables [ " lhs " ] as? O , variables [ " rhs " ] != nil , let arguments = variables [ " arguments " ] as? String else { return nil }
402402 var interpretedArguments : [ String : Any ] = [ : ]
403403 for argument in arguments. split ( separator: " , " ) {
404- let parts = String ( argument) . trim ( ) . split ( separator: " = " )
404+ let parts = String ( argument) . trimmingCharacters ( in : . whitespacesAndNewlines ) . split ( separator: " = " )
405405 if let key = parts. first, let value = parts. last {
406406 interpretedArguments [ String ( key) ] = interpreter. evaluate ( String ( value) )
407407 }
0 commit comments