[ 
https://issues.apache.org/jira/browse/GROOVY-9507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17083963#comment-17083963
 ] 

Paul King commented on GROOVY-9507:
-----------------------------------

The issue can illustrated outside templates and seems to be an issue with the 
grammar. It can be simplified to:
{code}
null.each { ; x = 0 }
{code}
which passes under 2.5.x but fails in 3+ with:
{noformat}
Unexpected input: '{'; Expecting <EOF> at line: 1, column: 11
{noformat}
It can be fixed by removing the unneeded semicolon. I don't know whether we 
could adjust StreamingTemplateEngine to do that but seems worth seeing if the 
grammar can be tweaked first.


> JSP style loop in StreamingTemplateEngine template results in 
> TemplateParseException
> ------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9507
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9507
>             Project: Groovy
>          Issue Type: Bug
>          Components: Templating
>    Affects Versions: 3.0.3
>            Reporter: Christopher Chase
>            Priority: Major
>
>  
> The example below works as expected when run in Groovy 2.5.8, yet it fails 
> when run in Groovy 3.0.3
>  
>  
> {code:java}
> TemplateEngine engine = new StreamingTemplateEngine()
> Template template = engine.createTemplate('''
> <ul>
>     <% items.each { %>
>     <li>${it}</li>
>     <% } %>
> </ul>
> ''')
> println template.make([items : [1,2,3,4]])
> {code}
>  
> Expected output (and the output 2.5.8 yields):
>  
> {noformat}
> <ul>
>   <li>1</li>
>   <li>2</li>
>   <li>3</li>
>   <li>4</li>
> </ul>{noformat}
>  
> Exception 3.0.3 gives:
>  
> {noformat}
> 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>{noformat}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to