grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 951 forks source link

New Feature: Allow views to specify a specific plugin layout in order to avoid conflicts #10110

Open ilopmar opened 8 years ago

ilopmar commented 8 years ago

I have a Grails 3.1.10 plugin and application in a gradle multi-project with the following setup:

The expected behaviour is that the layout from the plugin is applied. This works in Grails 2.3.6.

Actual Behaviour

The layout is not applied although the view is rendered correctly (but without the layout)

Environment Information

I've created a sample app that reproduces the problem: https://github.com/ilopmar/grails3-layout-and-view-plugin.

After cloning the repo:

cd myapp
grails run-app

And then open the browser and go to http://localhost:8080/foo/index

You will see the content of the plugin view but without the layout applied.

If now (without stopping the application) move the file myplugin/grails-app/views/layouts/main.gsp to myapp/grails-app/views/layouts/main.gsp` and reload the page, the layout is applied.

graemerocher commented 8 years ago

Possibly relates to #10047

graemerocher commented 8 years ago

The root cause of this issue is because the cache plugin also defines a grails-app/views/layouts/main.gsp layout. If you were to rename the layout to something else it starts working.

At the moment we have no mechanism to specify a specific plugin layout to apply so layouts have to have unique names.

Another option is to use loadBefore / loadAfter to ensure the plugin loads earlier than cache.

ilopmar commented 8 years ago

Using def loadAfter = ['cache'] as you suggested did the trick. Thanks!