Changeset 7629
- Timestamp:
- 09/25/07 14:57:15 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/layout.rb
r7514 r7629 235 235 protected 236 236 def render_with_a_layout(options = nil, &block) #:nodoc: 237 if template_with_options = options.is_a?(Hash) 238 response.template.template_format = options[:content_type].to_sym if options[:content_type] 239 end 240 237 template_with_options = options.is_a?(Hash) 238 set_template_format(options) 239 241 240 if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options)) 242 241 assert_existence_of_template_file(layout) … … 308 307 end 309 308 end 309 310 def set_template_format(options) 311 if options.is_a?(Hash) && options[:content_type] 312 response.template.template_format = options[:content_type].to_sym 313 elsif params[:format] 314 response.template.template_format = Mime::Type.lookup(Mime::Type.lookup_by_extension(params[:format]).to_s).to_sym 315 end 316 end 310 317 end 311 318 end trunk/actionpack/test/controller/mime_responds_test.rb
r7625 r7629 117 117 def iphone_with_html_response_type 118 118 Mime::Type.register_alias("text/html", :iphone) 119 119 request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" 120 120 121 respond_to do |type| 121 122 type.html { @type = "Firefox" } … … 400 401 get :iphone_with_html_response_type, :format => "iphone" 401 402 assert_equal "text/html", @response.content_type 402 assert_equal "<html>Hello future from iPhone!</html>", @response.body403 assert_equal "<html>Hello iPhone future from iPhone!</html>", @response.body 403 404 end 404 405