stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 223 forks source link

Add a protocol for keying into variables. #151

Closed jimstudt closed 6 years ago

jimstudt commented 6 years ago

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.

ilyapuchka commented 6 years ago

@jimstudt #152 should solve superclass properties issue without need for extra protocol