-
Notifications
You must be signed in to change notification settings - Fork 225
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
extended context to enable implementation of swiftlike scoping rules … #198
Conversation
…(pushLocals function) added a testcase for this new behavior modified ForTag to make use of this new mechanism
Hi @kaygro, I'm having a hard time trying to understand what you are trying to solve that is different from the |
If you want to to implement an extension, which has a set tag (as StencilSwiftKit for example), |
Exampe Stencil code for this scenario would look like:
I'd like to stress, that this modification does not implement a set tag, but merely enables implementation of a set tag, that works like this. |
Not sure about this change, feels too invasive, also I think it can be implemented in a simpler way, but I didn't explore it enough to be sure. Also I think current behaviour is the same as in Jinja.
Of course you'll need to implement this filter and register it in environment, so there is no way to do it just with templates. |
Well, I think it can be implemented entriely from within the set node, but that would mean, the implementation of the set node would need to make copies at the various heights of the context stack, where that variable is visible, (for every variable change that is). It would be less cubersome, if we could observe/override the subscript operators of the Context class, but that is not possible due to access beeing public, not open and Context not being a protocol. |
@kaygro I get what this is trying to achieve (seeing the issues with It might be better to have a mechanism in Context to directly modify the stack, so that |
I like that idea. I didn't realize, you could have multiple parameters in subscript operators. |
Closing this due to inactivity. |
…(pushLocals function)
added a testcase for this new behavior
modified ForTag to make use of this new mechanism