From e0a0b3fe8ee15cc6e8d7f3cbdb59b49fbd0c7606 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Mon, 15 Mar 2021 11:07:08 +0000 Subject: [PATCH] Extend String methods to Substring --- Sources/HummingbirdMustache/Method.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/HummingbirdMustache/Method.swift b/Sources/HummingbirdMustache/Method.swift index 20d2a13..6f30375 100644 --- a/Sources/HummingbirdMustache/Method.swift +++ b/Sources/HummingbirdMustache/Method.swift @@ -3,9 +3,11 @@ protocol HBMustacheMethods { func runMethod(_ name: String) -> Any? } -extension String: HBMustacheMethods { +extension StringProtocol { func runMethod(_ name: String) -> Any? { switch name { + case "capitalized": + return self.capitalized case "lowercased": return self.lowercased() case "uppercased": @@ -18,6 +20,9 @@ extension String: HBMustacheMethods { } } +extension String: HBMustacheMethods {} +extension Substring: HBMustacheMethods {} + protocol HBComparableSequence { func runComparableMethod(_ name: String) -> Any? }