On non-macOS platforms key value coding can not be used to extract values from variables. The introspection strategy works, but only for fields of the topmost class. Superclass fields are not visible. This makes any kind of hierarchical classes problematic.
This PR adds a protocol with a single function which works like the key value coding func value(key)->Any?.
The advantages are:
cross platform safe
allows the Stencil templates to use names which are different from the internal implementation names of the underlying Swift files
allow the Swift types to limit what they export to the template engine
faster than KVC or introspection
I've placed the RenderKeyed protocol above KVC or it would not be used on macOS.
On non-macOS platforms key value coding can not be used to extract values from variables. The introspection strategy works, but only for fields of the topmost class. Superclass fields are not visible. This makes any kind of hierarchical classes problematic.
This PR adds a protocol with a single function which works like the key value coding
func value(key)->Any?
.The advantages are:
I've placed the RenderKeyed protocol above KVC or it would not be used on macOS.