Search code examples
templatesgrailsgsp

Using partial template under view root


I have a partial template I'm including in my main.gsp.

This partial content will be slightly differnt for each controller/page on the site. Therefore I will have a seperate _headerDetails.gsp for each view directory.

This works fine except for the default application index.gsp. When I include a _headerDetails.gsp under root view directory I get the following error:

org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: Template not found for name [headerDetails] and path [//_headerDetails.gsp]

Does grails not allow partials in the root directory?

Main.gsp

<html>
    <head>
        <g:layoutTitle/>
        <r:layoutResources/>
        <link href="${resource(dir: 'css', file: 'style.css')}" type="text/css" rel="stylesheet">
    </head>

    <body class="home">

        <div id="wrapper">

            <div id="page_top"></div>

            <div id="content">
                <g:render template="/common/header" />

                <g:render template="headerDetails" />

                <br class="clear" />

                <g:layoutBody/>

                <br class="clear" />

            </div>

            <div id="page_bottom"></div>

            <g:render template="/common/footer" />  

        </div>

        <r:layoutResources/>

   </body>
</html>

Solution

  • is it headDetails or headerDetails??

    if its not a typo issue, try using a / before the template name to get to the root dir!