I have a Grails app which pulls in several Grails Plugins. These plugins need to be reused by several other Grails apps not just my own.
In a Resources Bundle in one of the Grails Plugins I have the following defined: leaving this for completeness, but I have since switched to the Asset-Pipline
modules = {
directivea {
resource url: 'directives/directivea/directivea.js'
resource url: 'services/restapis.js'
}
}
In a Javascript file in one of the plugins I have the following directive defined:
ModuleA.directive('directivea',function() {
return {
restrict: 'EA',
scope: {
'objId' : '='
},
replace: true,
link: function(){
$scope.ObjId = attributes[''];
$scope.someFunction($scope.ObjId);
},
controller: function(){
$scope.someFunction = function(objId){
//some stuff happens here
};
},
templateUrl: 'directives/directivea/directivea.html'
}
});
It seems to be executing the controller just fine but when it tries to pull in the template it chokes on:
GET /appname/directives/directivea/directivea.html 404 (Not Found)
This makes sense because that's not where the partial template will be. Where would it be though? How can I keep that information isolated to within the plugin but usable by all the downstream applications? I'd like to avoid defining in-line templates if I can.
**EDIT TO INCLUDE STRUCTURE**
Structure of Plugin:
- grails-app
- conf
- PluginNameForGrailsResources.groovy
- BuildConfig.groovy
- controllers
- PluginControllerA.groovy
- PluginControllerB.groovy
- domain
- PluginDomainA.groovy
- conf
- web-app
- css
- directives
- directivea
- directivea.js
- directivea.html
- directivea
- services
- restapis.js
- application.properties
- PluginNameForGrailsGrailsPlugin.groovy
Structure of the application referencing my Plugin:
- grails-app
- conf
- BuildConfig.groovy
- controllers
- domain
- views
- layouts
- main.gsp
- index.gsp (references to directivea via resources r:require tag)
- layouts
- web-app
- css
- main.css
- js
- index.js
- application.properties
**EDIT TO INCLUDE STRUCTURE POST-ASSET-PLUGIN-SWITCHOVER** no more Resources defined, BuildConfig.groovy now references the asset pipline instead of Resources, no more files in web-app
- grails-app
- conf
- BuildConfig.groovy
- controllers
- PluginControllerA.groovy
- PluginControllerB.groovy
- domain
- PluginDomainA.groovy
- assets
- javascripts
- directivea
- directivea.js
- directivea.html
- services
- restapis.js
- directivea
- application.properties
- PluginNameForGrailsGrailsPlugin.groovy
- javascripts
- conf