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

Loop Variables Not Resolving when used in string interpolations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.26-incubating
    • 2.3.27-incubating
    • engine
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: