module ActionController::Rendering
Constants
- RENDER_FORMATS_IN_PRIORITY
Public Instance Methods
render_to_body(options = {})
click to toggle source
Calls superclass method
# File lib/action_controller/metal/rendering.rb, line 51 def render_to_body(options = {}) super || _render_in_priorities(options) || " " end
render_to_string(*)
click to toggle source
Overwrite render_to_string
because body can now be set to a Rack
body.
Calls superclass method
# File lib/action_controller/metal/rendering.rb, line 40 def render_to_string(*) result = super if result.respond_to?(:each) string = +"" result.each { |r| string << r } string else result end end
Private Instance Methods
_normalize_args(action = nil, options = {}, &blk)
click to toggle source
Normalize arguments by catching blocks and setting them on :update.
Calls superclass method
# File lib/action_controller/metal/rendering.rb, line 87 def _normalize_args(action = nil, options = {}, &blk) options = super options[:update] = blk if block_given? options end
_normalize_options(options)
click to toggle source
Normalize both text and status options.
Calls superclass method
# File lib/action_controller/metal/rendering.rb, line 94 def _normalize_options(options) _normalize_text(options) if options[:html] options[:html] = ERB::Util.html_escape(options[:html]) end if options[:status] options[:status] = Rack::Utils.status_code(options[:status]) end super end
_normalize_text(options)
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 108 def _normalize_text(options) RENDER_FORMATS_IN_PRIORITY.each do |format| if options.key?(format) && options[format].respond_to?(:to_text) options[format] = options[format].to_text end end end
_process_options(options)
click to toggle source
Process controller specific options, as status, content-type and location.
Calls superclass method
# File lib/action_controller/metal/rendering.rb, line 117 def _process_options(options) status, content_type, location = options.values_at(:status, :content_type, :location) self.status = status if status self.content_type = content_type if content_type headers["Location"] = url_for(location) if location super end
_process_variant(options)
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 56 def _process_variant(options) if defined?(request) && !request.nil? && request.variant.present? options[:variant] = request.variant end end
_render_in_priorities(options)
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 62 def _render_in_priorities(options) RENDER_FORMATS_IN_PRIORITY.each do |format| return options[format] if options.key?(format) end nil end
_set_html_content_type()
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 70 def _set_html_content_type self.content_type = Mime[:html].to_s end
_set_rendered_content_type(format)
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 74 def _set_rendered_content_type(format) if format && !response.media_type self.content_type = format.to_s end end
_set_vary_header()
click to toggle source
# File lib/action_controller/metal/rendering.rb, line 80 def _set_vary_header if self.headers["Vary"].blank? && request.should_apply_vary_header? self.headers["Vary"] = "Accept" end end