You can actually accomplish this using Sitemesh Content blocks, instead of writing custom Grails tags:
On your layout page put this (to replace renderDependantJavascript):
<g:pageProperty name="page.javascript"/>
And on the decorated page put this (to replace dependantJavascript):
<content tag="javascript">
<script src="thisPageSpecificScriptDependantOnGlobal.js"></script>
</content>
Note that you will need to use the SiteMesh HTMLPageParser in place of FastPageParser (which has been deprecated). HTMLPageParser is used as of Grails 1.1.1, but if you don't want to upgrade Grails, you can go to sitemesh.xml and replace all instances of FastPageParser with HTMLPageParser
ie:
<parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
dear_stephen wrote:
I have come up with a solution that works well. I created the following tags.
def dependantJavascript = { attrs, body ->
flash.dependantJavascript = body()
}
def renderDependantJavascript = {
out << flash.dependantJavascript
}
In my desorated page I have ...
<g:dependantJavascript>
<script src="thisPageSpecificScriptDependantOnGlobal.js"></script>
</g:dependantJavascript>
In my decorator page I put the following.
<script src="global.js" />
<g:renderDependantJavascript />