I want to include a javascript file custom.js
in my gsp from a plugin. My main app uses this plugin as a dependency. The custom.js
javascript file contains a variable whose value is obtained by executing grails code within GString
.
var root = "${request.contextPath}";
It has to be a separate file and if I try to include it inside my .gsp file using <script src="custom.js"></script>
the grails code doesn't get executed. If I use <g:javascript src="custom.js" />
it tries to fetch the file from within the plugin and cannot find it. The file is actually in my main application. But the code that's trying to include it is in the plugin. Something like a way of providing custom Javascript implementation. How do I go about this?