Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-22152

In velocity, can't use $macro.myVar with setVariable macro

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Hello,

      In velocity for now, we can't use the '$macro.myVar' to retrieve the result of a child macro. Because of this limitation we must use a global variable (which as a risk of conflict with an other part of code which use the same variable.

      Let's take an example:

      #macro(myChildMacro $return)
        #set($return = $NULL)
        #setVariable("$return" "my new value")
      #end
      
      #macro(myParentMacro)
        #myChildMacro($macro.childResult)
        $macro.childResult
      #end
      
      #myParentMacro()
      

      This code won't work, so we have this result

      $macro.childResult
      

      This is because we call 'myChildMacro' with the variable '$macro.childResult'. To make it working, instead we must use a global variable like '$childResult' which is in the global context.

      Attachments

        Activity

          People

            josue Josué Tille
            josue Josué Tille
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: