Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9507

JSP style loop in StreamingTemplateEngine template results in TemplateParseException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.3
    • Fix Version/s: 4.0.0-alpha-1, 3.0.4
    • Component/s: Templating
    • Labels:
      None

      Description

       

      The example below works as expected when run in Groovy 2.5.8, yet it fails when run in Groovy 3.0.3

       

       

      TemplateEngine engine = new StreamingTemplateEngine()
      
      Template template = engine.createTemplate('''
      <ul>
          <% items.each { %>
          <li>${it}</li>
          <% } %>
      </ul>
      ''')
      
      println template.make([items : [1,2,3,4]])
      

       

      Expected output (and the output 2.5.8 yields):

       

      <ul>
          
          <li>1</li>
          
          <li>2</li>
          
          <li>3</li>
          
          <li>4</li>
          
      </ul>
      

       

      Exception 3.0.3 gives:

       

      Exception in thread "main" groovy.text.TemplateParseException: Template parse error 'Unexpected input: '{'; Expecting RBRACE ' at line 3, column 27
               2:         <ul>
           --> 3:             <% items.each { %>
               4:             <li>${it}</li>

       

       

        Attachments

          Activity

            People

            • Assignee:
              daniel_sun Daniel Sun
              Reporter:
              cchase88 Christopher Chase
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: