0

I have a template which I render with:

<g:render template="recordInfo" />

in my main-layout. (layout/main.gsp).

That's a template, which some of my views need and some views don't.

For the views, which don't need that template, I put an empty file with the name in the top-level-views directory (/grails-app/views). As described in the grails documentation:

Without the leading '/' it will be first be resolved relative to the 
current controller's view directory then, failing that, the top level 
views directory.

It works fine for the views which have the template-file in the own view-directory (e.g. /grails-app/views/address). But it doesn't work, where grails should search the template at the /grails-app/views level.

Do I understand something wrong from the documentation or do I have an error in my code?

My file/directory structure looks like:

...
MyApp/grails-app/views/_recordInfo.gsp
MyApp/grails-app/views/address/_form.gsp
MyApp/grails-app/views/address/ ...
MyApp/grails-app/views/address/_recordInfo.gsp
MyApp/grails-app/views/contact/_form.gsp
MyApp/grails-app/views/contact/ ...
...

The address-view needs a customized _recordInfo template and the contact-view don't need it (and therefore I thought grails would pick up the one in the MyApp/grails-app/views directory...)

susi
  • 493
  • 4
  • 13
  • just out of curiosity: can you tell, why you want that `recordInfo.gsp` rendered from the main layout? Are trying to use the main layout as a generic `show` view that renders the corresponding show information (with `recordInfo`) of a record, right? – Mario David May 06 '15 at 17:48
  • The recordInfo.gsp contains some javascript-snipplets, which differ for the pages, which need this gsp (they refer to the fields in the _form-views). And they need to run after a few js-scripts, which are loaded in the bottom of the main-layout. (And the g:render tag is behind them.) But I puzzle about, if I understand the documentation wrong... – susi May 07 '15 at 07:15

0 Answers0