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

Avoid tag cycles when keeping track of parent paths for blocks #363

Merged
merged 3 commits into from
Aug 23, 2019

Conversation

liamrharwood
Copy link
Contributor

Fix for #359 because it was causing TagCycleExceptions when pushing a parent path onto the currentPathStack.

This changes the solution from that PR so that it will only push the parent path onto the stack if the stack does not already contain the parent path. For instance, this handles a situation where a template using extends/block is included in a different template, so the path is already in the stack.

This also will only pop the parent path off the stack if it was pushed onto the stack to begin with.

for (Node child : block) {
for (Node child : block.getNodes()) {
boolean pushedParentPathOntoStack = false;
if (block.getParentPath().isPresent() && !getContext().getCurrentPathStack().contains(block.getParentPath().get())) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will only push the parent path onto the stack if the stack does not already contain the parent path

blockValueBuilder.addNode(child.render(this));

if (pushedParentPathOntoStack) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also will only pop the parent path off the stack if it was pushed onto the stack to begin with

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