XWIKI-22152 In velocity, can't use $macro.myVar with setVariable macro #3108
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.
Jira URL
https://jira.xwiki.org/browse/XWIKI-22152
Changes
Description
Add support for variable like
$macro.myvar
insetVariable
velocity macro.Clarifications
So to fix the described issue, the idea is to improve the
setVariable
macro to be able to set correctly the value when the caller pass a parameter to set with something like this$macro.xxx
.For this we need the
$macro.parent
which give access to the$macro
dict of the caller. Note that we need to call$macro.parent.parent
because$macro.parent
return the macro which is callingsetVariable
and so we want to call the parent of this one.Executed Tests
To test this we can use this small code
Before we have this result
After we have this result:
Expected merging strategy