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

JSP style loop in StreamingTemplateEngine template results in TemplateParseException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.3
    • 4.0.0-alpha-1, 3.0.4
    • Templating
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: