Recently in the Grails Filterpane Plugin I had to figure out a way to allow users to selectively override the bundled template files that were rendered in the filterpane taglib. I was able to achieve this through a bit of simple code that may be helpful to plugin authors in the future.
The bit of magic in the code below is the line
groovyPageLocator.findTemplateInBinding(path, pageScope). This equates to is asking grails to find a template for the path in the project scope. I then check if the result of the call is null and append the filterpane plugin to the resulting map causing the render to use the plugin vs the local template. This works well because apparently you can specify
plugin: null in the render block which is the same as saying “use the current project scope”.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18