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>
                is it headDetails or headerDetails?? 
if its not a typo issue, try using a / before the template name to get to the root dir!
<g:if test="${params.action.equals('')}">
  <g:render template="/headerDetails" />
</g:if>  
<g:else>
  <g:render template="headerDetails" />
</g:else>
                        See chapter "Template basics > Shared templates" of the grails docs:
http://grails.org/doc/2.0.x/guide/theWebLayer.html#viewsAndTemplates
In this case you can place them in the root views directory at
grails-app/viewsor any subdirectory below that location, and then with the template attribute use an absolute location starting with/instead of a relative location. For example if you had a template calledgrails-app/views/shared/_mySharedTemplate.gsp, you would reference it as:<g:render template="/shared/mySharedTemplate" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With