module AbstractController::Rendering
def _normalize_args(action=nil, options={})
render :file => "foo/bar".
render :action => "foo" and render "foo/bar" to
Normalize args by converting render "foo" to
def _normalize_args(action=nil, options={}) if action.respond_to?(:permitted?) if action.permitted? action else raise ArgumentError, "render parameters are not permitted" end elsif action.is_a?(Hash) action else options end end
def _normalize_options(options)
Normalize options.
def _normalize_options(options) options end
def _normalize_render(*args, &block)
Normalize args and options.
def _normalize_render(*args, &block) options = _normalize_args(*args, &block) #TODO: remove defined? when we restore AP <=> AV dependency if defined?(request) && !request.nil? && request.variant.present? options[:variant] = request.variant end _normalize_options(options) options end
def _process_format(format)
Process the rendered format.
def _process_format(format) end
def _process_options(options)
Process extra options.
def _process_options(options) options end
def _protected_ivars # :nodoc:
def _protected_ivars # :nodoc: DEFAULT_PROTECTED_INSTANCE_VARIABLES end
def _set_html_content_type # :nodoc:
def _set_html_content_type # :nodoc: end
def _set_rendered_content_type(format) # :nodoc:
def _set_rendered_content_type(format) # :nodoc: end
def render(*args, &block)
sticks the result in self.response_body.
Normalizes arguments, options and then delegates render_to_body and
def render(*args, &block) options = _normalize_render(*args, &block) rendered_body = render_to_body(options) if options[:html] _set_html_content_type else _set_rendered_content_type rendered_format end self.response_body = rendered_body end
def render_to_body(options = {})
Performs the actual template rendering.
def render_to_body(options = {}) end
def render_to_string(*args, &block)
overridden in order to still return a string.
responds to the method each), this method needs to be
(as ActionController extends it to be anything that
If a component extends the semantics of +response_body+
to always return a string.
set the +response_body+ and it should be guaranteed
It is similar to render, except that it does not
Raw rendering of a template to a string.
def render_to_string(*args, &block) options = _normalize_render(*args, &block) render_to_body(options) end
def rendered_format
Returns Content-Type of rendered content
def rendered_format Mime[:text] end
def view_assigns
You can overwrite this configuration per controller.
This method should return a hash with assigns.
def view_assigns protected_vars = _protected_ivars variables = instance_variables variables.reject! { |s| protected_vars.include? s } variables.each_with_object({}) { |name, hash| hash[name.slice(1, name.length)] = instance_variable_get(name) } end