This project is archived and is in readonly mode.
layout chaining
-
José Valim
This won't break current applications?
For example, if I do in my ApplicationController:
class ApplicationController < ActionController::Base
layout 'default'end
And then:
class AdminController < ApplicationController
layout 'admin'end
Since you are using inheritable array I'm almost sure that this will nest the layout, right?
And I can't see also any use case for this feature.
-
JasonKing
That use case doesn't change. The last layout called is the one that takes precedence, and because the last layout called has no conditions then it will be used for all actions on AdminController.
Here's a use case showing the effect of this patch:
class FoosController < ApplicationController layout 'products' layout 'login', :only => 'login' layout 'forum', :only => 'forum' endRight now this will just cause confusion because actually both :only conditions are stored, but only the 'forum' layout will ever be rendered.
With my chaining patch, the behaviour will be far more as one would expect, with each condition only applying to corresponding template, and chaining back through the layouts until it finds one that applies for the called action.
-
José Valim
I think now I got it. The name totally confused me as I thought that you would nest one layout inside the other (which makes no sense). Maybe you could change the title? :)
-
Ryan Angilly
I haven't ran this patch, but +1 for concept
-
Jeremy Olliver
Sounds like a good idea to me too.
The patch doesn't apply cleanly to the current master though, could you update the patch with the latest master?
-
JasonKing
Email notifications aren't working for me - sorry for the delay :(
Just rebased, should be good now.
-
Matt Jones
As this has been punted to the next release, I've updated the guide to correctly reflect the current behavior.
-
CancelProfileIsBroken
- Assigned user set to Yehuda Katz (wycats)
Any thoughts on how this will behave in 3.0? We shouldn't make this change on 2.x unless 3.0 will behave the same way.
-
Yehuda Katz (wycats)
I really don't like this idea at all. It looks like another example of moving app-specific logic with very uncommon use-cases into a core location in the framework. Every such innocuous change adds more complexity to the overall system, including parts of Rails that are only tangentially related.
Why could this not be achieved with an in-app helper that captured the content with its appropriate layout and then using that capture in the layout. I'd personally be much more amenable to a helper that made that sort of thing easier than in adding more complexity to the already non-trivial layout system.
-
CancelProfileIsBroken
- State changed from new to wontfix
The helper solution seems more likely to work cleanly in both 2.x and 3.0 if you want to pursue it.
-
JasonKing
Have you guys seen my second comment in this ticket?
Where multiple layout statements with conditions will have their conditions combined, but the template itself is overwritten.
There are two options that I can see to solve this, one was the layout chaining idea that I was investigating in this patch, the other is to ensure that previous conditions are cleared/overwritten when processing the layout call.
This issue shouldn't be closed until one of those is done.
