Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a protocol for keying into variables. #151

Closed
wants to merge 3 commits into from

Conversation

jimstudt
Copy link

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.

@ilyapuchka
Copy link
Collaborator

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

@ilyapuchka ilyapuchka closed this Dec 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants