I have a layout main.gsp including scripts before the /body tag:
<g:pageProperty name="page.scripts" />
Index.gsp is a page which has main.gsp has a template, and uses <content tag="scripts">
to include some javascript, so that all scripts stay nicely together before the /body tag
I have my template with I include in my page (index.gsp) with the following instruction:
<g:render template="postbox" />
for this template to reusable and independent, it needs its own script. How can I include it and have it placed right before the /body tag? If I use <content tag="scripts">
it overwrites the scripts I declared in index.gsp
In my opinion you should use the Grails Resources Plugin. This plugin will organize your javascript code, javascript dependencies, and you can modularize your javascript files so that some pages (or templates) depend on specific javascript files.
You will be able to create a postbox.js file , and declare in your _postbox.gsp template that it depends on postbox.js script.
The plugin will even go further and decide if it is best to put the script before the body tag, or at the end of your html file right before /body tag. It implements best practices for JS and CSS manipulation. Great stuff.