Search code examples
htmlgrailsgsp

GSP Template fails to retrieve passed template from another template


I'm working on a Grails 2.4.4 project. I have the following code on my gsp page (not a template) that calls a sub template that calls another template: main gsp page > gsp template > yet another gsp template:

main.gsp

...
<g:render template="/details" model="[param_one:'param_one', param_two:'param_two']" />
...

_details.gsp

...
<p>On details: ${param_one}</p>
<g:render template="/segments/segment-one" model="[param_two:'${param_two}']" />
...

_segment-one.gsp

<p>Segment One: ${param_two}</p>

Now when it renders the whole page, it only shows something like this:

On details: param_one
Segment One: ${param_two}

Why does _segment-one.gsp fails to render the passed param_two? Is it not allowed to have template from another template rendering? Thanks guys.


Solution

  • I fixed the code in _segment-one.gsp by adding the params keyword:

    <p>Segment One: ${params.param_two}</p>
                      ^^^^^^