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

Wrap the current path around reconstructed macro functions #1199

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

jasmith-hs
Copy link
Contributor

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 with current_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:

  1. Wrap the reconstruction of macro functions with the new and then initial current_path so that we keep the current_path accurate to what it should be if you are to run the output of eager execution through a final rendering pass.
  2. If the context has a current_path key when Jinjava.renderForResult is called, then initialize the currentPathCallStack with that value.

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.

1 participant