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

Keep meta context variables when importing #1187

Merged
merged 3 commits into from
May 18, 2024

Conversation

jasmith-hs
Copy link
Contributor

Meta context variables denote those which have special meaning outside the context of the Jinjava template. In HubL, this includes variables like content.

If these are manually overridden, such as inside a set tag or a for tag, then the lose their special functionality. This is mirrored by the set of metaContextVariables which can have keys removed inside of a set tag or for tag.

If a meta context variable is removed and then an import tag is run, the meta context variable will re-appear due to the prepareContext method getting run again, which is used to re-add meta context variables.

This PR adds a new method getComputedMetaContextVariables() and deprecates the old getMetaContextVariables() method. This allows overrides to be added and removed without affecting the core metaContextVariables. So running prepareContext again does not cause issues as the core set of metaContextVariables won't have had any elements removed since any previous prepareContext runs.

…cution mode already.

This prevents having the meta-context variables get overridden when evaluating an import as it creates a new JinjavaInterpreter based on the current one, which will share the same metaContextVariables set
…riddenMetaContextVariables.

This makes it so that metaContextVariables never have values get removed from them so that running prepareContext can multiple times without issue
@jasmith-hs jasmith-hs merged commit c3eb356 into master May 18, 2024
5 checks passed
@jasmith-hs jasmith-hs deleted the keep-meta-context-variables branch May 18, 2024 02:52
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