Changeset 1369
- Timestamp:
- 05/30/05 07:51:02 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/layout.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/new_render_test.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/send_file_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r1367 r1369 1 1 *SVN* 2 3 * render(:text), render(:partial), and render(:nothing) always default to :layout => false. This also fixes send_file, which was applying a layout if one existed for the current action. 2 4 3 5 * verify with :redirect_to won't redirect if a redirect or render has already been performed #1350 trunk/actionpack/lib/action_controller/layout.rb
r1353 r1369 145 145 # If most of your actions use the same layout, it makes perfect sense to define a controller-wide layout as described above. 146 146 # Some times you'll have exceptions, though, where one action wants to use a different layout than the rest of the controller. 147 # This is possible using <tt>render_with_layout</tt> method. It's just a bit more manual work as you'll have to supply fully147 # This is possible using the <tt>render</tt> method. It's just a bit more manual work as you'll have to supply fully 148 148 # qualified template and layout names as this example shows: 149 149 # 150 150 # class WeblogController < ActionController::Base 151 151 # def help 152 # render _with_layout "help/index", "200","layouts/help"152 # render :file => "help/index", :layout => "layouts/help" 153 153 # end 154 154 # end … … 204 204 205 205 def render_with_a_layout(options = {}, deprecated_status = nil, deprecated_layout = nil) #:nodoc: 206 if (layout = pick_layout(options, deprecated_layout)) && options.is_a?(Hash) && options[:text] 206 options = render_with_a_layout_options(options) 207 if (layout = pick_layout(options, deprecated_layout)) 207 208 logger.info("Rendering #{options[:template]} within #{layout}") unless logger.nil? 208 209 … … 218 219 219 220 private 221 def render_with_a_layout_options(options) 222 return options unless options.is_a?(Hash) 223 case 224 when options[:text], options[:partial], options[:nothing] 225 # by default, :text, :partial, and :nothing never use a layout 226 { :layout => false }.merge(options) 227 else 228 options 229 end 230 end 231 220 232 def pick_layout(options = {}, deprecated_layout = nil) 221 return deprecated_layout if !deprecated_layout.nil? || (options.is_a?(Hash) && options[:nothing])233 return deprecated_layout if !deprecated_layout.nil? 222 234 223 235 if options.is_a?(Hash) trunk/actionpack/test/controller/new_render_test.rb
r1366 r1369 74 74 def partial_only 75 75 render :partial => true 76 end 77 78 def partial_only_with_layout 79 render :partial => "partial_only", :layout => nil 76 80 end 77 81 … … 90 94 def determine_layout 91 95 case action_name 92 when "layout_test", "rendering_without_layout", "rendering_nothing_on_layout" 96 when "layout_test", "rendering_without_layout", 97 "rendering_nothing_on_layout", "render_text_hello_world", 98 "partial_only", "partial_only_with_layout" 93 99 "layouts/standard" 94 100 when "builder_layout_test" … … 220 226 end 221 227 228 def test_partial_only_with_layout 229 get :partial_only_with_layout 230 assert_equal "<html>only partial</html>", @response.body 231 end 232 222 233 def test_render_to_string 223 234 get :hello_in_a_string trunk/actionpack/test/controller/send_file_test.rb
r400 r1369 11 11 class SendFileController < ActionController::Base 12 12 include TestFileUtils 13 layout "layouts/standard" # to make sure layouts don't interfere 13 14 14 15 attr_writer :options … … 21 22 end 22 23 24 SendFileController.template_root = File.dirname(__FILE__) + "/../fixtures/" 23 25 24 26 class SendFileTest < Test::Unit::TestCase