Pages

November 04, 2012

Grails r:script and g:include - workaround

Hi,
As others did, I also bumped into this mess. I wanted to include a controller view into another view, and have the nested view contain JS which can be used on that view, but r:script and g:include are not best friends.
I found a workaround you might find useful as well. I simply add an empty r:script tag on the parent view (the one who is using the include) and that's it, like this:

Parent view, on the HEAD tag:
 

And in the nested view:

// Script here


Mind you that we're counting on using the main.gsp layout (or some other layout which supports r:script)

1 comment:

Jeltok said...

Thank you! Worked like charm for me.