Search code examples
grailsclosuresgsp

Double closure fails in GSP


In a GSP file I write something like this:

${tgs.singleGameSheets.find{it.matchnumber==1}.awayPlayer.fullname()}

But I receive the following error:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: C__STS_Projekte_TischtennisManager_grails_app_views_league__showGameSheet_gsp: 49:expecting '}', found ')' @ line 49, column 134. heets.find{it.matchnumber==1 })

The problem seems to be the double closure as I've found a bug report here.

Unfortunately the solution from the bugreport with the %= and % at the beginning and the end of the tag is not working for me.

Are there any other workarounds or solutions for this double closure problem?

I'm using Grails 1.3.7.


Solution

  • You may have to split this up in to two lines.

    Try assigning the find results to a separate var first

    <% def r = tgs.singleGameSheets.find{it.matchnumber==1} %>
    ${r*.awayPlayer.fullname()}