Ticket #307: AP-default_layouts_set_automatically.diff
| File AP-default_layouts_set_automatically.diff, 1.5 kB (added by marcel, 4 years ago) |
|---|
-
layout.rb
old new 2 2 module Layout #:nodoc: 3 3 def self.append_features(base) 4 4 super 5 base.extend(ClassMethods)6 5 base.class_eval do 7 6 alias_method :render_without_layout, :render 8 7 alias_method :render, :render_with_layout 8 class << self 9 alias_method :inherited_without_layout, :inherited 10 end 9 11 end 12 base.extend(ClassMethods) 10 13 end 11 14 12 15 # Layouts reverse the common pattern of including shared headers and footers in many templates to isolate changes in … … 119 122 def layout(template_name) 120 123 write_inheritable_attribute "layout", template_name 121 124 end 125 126 private 127 def inherited(child) 128 inherited_without_layout(child) 129 controller = child.controller_name 130 layout_name = controller.eql?('abstract_application') ? 'application' : controller 131 child.layout(layout_name) unless layout_list.grep(/^#{layout_name}\.r(?:xml|html)$/).empty? 132 end 133 134 def layout_list 135 Dir.glob("#{RAILS_ROOT}/app/views/layouts/*.r{xml,html}").map {|l| File.basename(l)} 136 end 122 137 end 123 138 124 139 # Returns the name of the active layout. If the layout was specified as a method reference (through a symbol), this method … … 145 160 render_without_layout(template_name, status) 146 161 end 147 162 end 163 148 164 end 149 165 end