public Method

Base.render(options = {}, old_local_assigns = {}, &block)

Renders the template present at template_path (relative to the view_paths array). The hash in local_assigns is made available as local variables.

Source Code

# File action_view/base.rb, line 330
def render(options = {}, old_local_assigns = {}, &block) #:nodoc:
  if options.is_a?(String)
    render_file(options, true, old_local_assigns)
  elsif options == :update
    update_page(&block)
  elsif options.is_a?(Hash)
    options = options.reverse_merge(:locals => {}, :use_full_path => true)

    if options[:layout]
      path, partial_name = partial_pieces(options.delete(:layout))

      if block_given?
        @content_for_layout = capture(&block)
        concat(render(options.merge(:partial => "#{path}/#{partial_name}")), block.binding)
      else
        @content_for_layout = render(options)
        render(options.merge(:partial => "#{path}/#{partial_name}"))
      end
    elsif options[:file]
      render_file(options[:file], options[:use_full_path], options[:locals])
    elsif options[:partial] && options[:collection]
      render_partial_collection(options[:partial], options[:collection], options[:spacer_template], options[:locals])
    elsif options[:partial]
      render_partial(options[:partial], ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals])
    elsif options[:inline]
      render_template(options[:type], options[:inline], nil, options[:locals])
    end
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.