Skip to content

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

Merged
liamrharwood merged 3 commits into
masterfrom
fix-relative-path-blocks
Aug 23, 2019
Merged

Avoid tag cycles when keeping track of parent paths for blocks#363
liamrharwood merged 3 commits into
masterfrom
fix-relative-path-blocks

Conversation

@liamrharwood

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@liamrharwood liamrharwood merged commit 04f2446 into master Aug 23, 2019
@liamrharwood liamrharwood deleted the fix-relative-path-blocks branch August 23, 2019 17:39
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