Keep meta context variables when importing#1187
Merged
jasmith-hs merged 3 commits intomasterfrom May 18, 2024
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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
metaContextVariableswhich 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
prepareContextmethod getting run again, which is used to re-add meta context variables.This PR adds a new method
getComputedMetaContextVariables()and deprecates the oldgetMetaContextVariables()method. This allows overrides to be added and removed without affecting the coremetaContextVariables. So runningprepareContextagain does not cause issues as the core set ofmetaContextVariableswon't have had any elements removed since any previousprepareContextruns.