Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-70

Loop Variables Not Resolving when used in string interpolations

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.26-incubating
    • Fix Version/s: 2.3.27-incubating
    • Component/s: engine
    • Labels:
      None

      Description

      When invoking a macro inside of a #list the loop variable is not in scope to be used resolving the argument values to the macro call.

      Example

      <#macro button caption>
      content irrelevant.
      </#macro>
      
      
      <#list ["a","b","c"]>
      <#items as loopvar>
      ${loopvar?counter} -- works
      ${loopvar?index} -- works
      <p class="${loopvar?index}"> -- works
      <@button caption="${loopvar?index}" /> -- FAILS
      </#items>
      </#list>
      
      

      The @button macro call fails with the message:
      The left hand operand of ?index must be a loop variable, but there's no loop variable in scope with this name: loopvar

      Shouldn't loopvar be in scope for evaluating those macro argument values?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bill_parkinson@yahoo.com Bill Parkinson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: