grails-gsp icon indicating copy to clipboard operation
grails-gsp copied to clipboard

g:render with body and g:set bug

Open demon101 opened this issue 7 years ago • 0 comments

Task List

  • [X] Full description of the issue provided (see below)
  • [X] Steps to reproduce provided
  • [X] Example that reproduces the problem uploaded to Github

Steps to Reproduce

index.gsp:

<g:render template="someTemplate">
    <g:set var="someVariable" value="Yes!"/>
    value: ${someVariable}
</g:render>

someTemplate.gsp

<%@ page contentType="text/html;charset=UTF-8" %>
Bla bla!
${raw(body())}
End

Expected Behaviour

render

Bla bla! value: Yes End

Actual Behaviour

Bla bla! value: End

Variable value is missing, null

Can be fixed by moving set out of render:

<g:set var="someVariable" value="Yes!"/>
<g:render template="someTemplate">
    value: ${someVariable}
</g:render>

Environment Information

  • Grails Version: 3.1.15, 3.2.8

Example Application

https://github.com/demon101/grails-trigers/tree/master/grails-app/views/test

demon101 avatar Apr 12 '17 13:04 demon101