Wrap the current path around reconstructed macro functions #1199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because macro functions can have different current paths due to their
localContextScope
potentially holding current path information as well as the import resource path, you could end up in a situation where within the macro function, the last reconstruction of{% set current_path = ... %}
sets the current path to the macro function's path. If originally deferred, but then run with nested interpretation, the current_path of the macro function could then override the current_path of the parent.This generally doesn't matter at all because the
currentPathCallStack
is used to determine the current path when resolving relative resource locations, but at HubSpot we initialize the current path withcurrent_path
and an empty call stack, which could end up having the wrong current path used for relative path resolution.I address this with 2 things:
current_path
so that we keep thecurrent_path
accurate to what it should be if you are to run the output of eager execution through a final rendering pass.current_path
key whenJinjava.renderForResult
is called, then initialize thecurrentPathCallStack
with that value.