Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-652

Macros encountered in templates are placed in global scope if no global library is specified and velocimacro.permissions.allow.inline.to.replace.global = false

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.6
    • 2.0
    • Engine
    • None

    Description

      This is a minor issue and more of a documentation/implementation mismatch. With default settings (allow.inline.to.replace.global=false, velocimacro.library not specified etc.) the first time a velocimacro is encountered in a template, it is placed in global scope and thus replaces all inline macros. Explicitly setting "allow.inline.to.replace.global=true" will cure the issue, even though it should have no effect as there are no global macros specified - hence nothing to replace! Albeit this is a configuration documentation issue, the behavior can be quite confusing and should probably be changed to have an empty global library if none is specified.

      Steps to reproduce:
      1) create new RuntimeInstance and only define the resource loader in properties
      2) create two templates, named test1.vtl and test2.vtl:

      — test1.vtl:
      #macro( myMacro )
      Macro A
      #end

      #myMacro()

      — test2.vtl:
      #macro( myMacro )
      Macro B
      #end

      #myMacro()

      3) first merge() test1.vm, should return "Macro A" (and it does)
      4) now merge() test2.vm, should return "Macro B" but returns "Macro A" instead
      5) create new RuntimeInstance with "velocimacro.permissions.allow.inline.to.replace.global = true"
      6) retry merging and observe correct behavior

      Attachments

        1. VelociMacroNamespaceTestCase.zip
          1.0 kB
          Lauri Piispanen

        Issue Links

          Activity

            People

              cbrisson Claude Brisson
              sunky Lauri Piispanen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: