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 resolved expressions recursively up the context chain #147

Merged
merged 5 commits into from
Aug 31, 2017

Conversation

jmp3833
Copy link
Contributor

@jmp3833 jmp3833 commented Aug 28, 2017

Rather than using addResolvedFrom to combine resolved expressions from multiple Context objects, it would be more widely applicable to recursively add resolved expressions up the parent context chain. This way information isn't lost when rendering a nested structure, with multiple nested contexts and resolved expressions.

@boulter do you think this would be worth applying to Context's resolved functions and values as well?

cc @hs-lsong

@jmp3833 jmp3833 self-assigned this Aug 28, 2017
@jmp3833 jmp3833 requested a review from boulter August 28, 2017 18:59
@hs-lsong
Copy link
Collaborator

Does jinjava has the concept of scope? If so, a child's expression may not be the same as the parent's. I do not have the context of this issue. Why do we need this?

@boulter
Copy link
Contributor

boulter commented Aug 28, 2017

I agree that we should do the same for function and variables too.

@jmp3833
Copy link
Contributor Author

jmp3833 commented Aug 28, 2017

@hs-lsong currently the Context objects aren't scoped, but a nested set of expressions will have a Context object applied to each expression. We would like the ability to traverse the entire collection of resolved expressions of any Context object from the root Context.

This way we can perform selective logic if we detected a certain resolved expression, function, or value after processing a large chunk of text with JinJava. We had been using the addResolvedFrom function to apply values up the context chain but rather than doing this on a case by case basis, it would be nice to have all of these values applied to the root Context all the time.

@jmp3833 jmp3833 merged commit b943faa into master Aug 31, 2017
@jmp3833 jmp3833 deleted the resolved-expressions-to-parent branch August 31, 2017 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants