This commit is contained in:
Adam Fowler
2021-03-15 15:09:16 +00:00
parent 978b14a96a
commit e391f5ae05
8 changed files with 70 additions and 27 deletions

View File

@@ -1,13 +1,12 @@
/// Protocol for object that has a custom method for accessing their children, instead
/// of using Mirror
protocol HBMustacheParent {
func child(named: String) -> Any?
}
extension HBMustacheParent {
// default child to nil
func child(named: String) -> Any? { return nil }
}
/// Extend dictionary where the key is a string so that it uses the key values to access
/// it values
extension Dictionary: HBMustacheParent where Key == String {
func child(named: String) -> Any? { return self[named] }
}