Class: ActionView::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ajax_scaffold_plugin.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#parse_partial_path(partial_path) ⇒ Object



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/ajax_scaffold_plugin.rb', line 488

def parse_partial_path(partial_path)
  path, partial_name = partial_pieces(partial_path)

  if partial_path.include?('/')
    unless (erb_template_exists?("#{path}/_#{partial_name}"))
      path, partial_name = partial_pieces(partial_name)
      partial_path = "#{path}/#{partial_name}"
    end
  end

  unless (erb_template_exists?("#{path}/_#{partial_name}"))
    partial_path = "ajax_scaffold/#{partial_name}"
  end

  partial_path
end

#render(options = {}, old_local_assigns = {}, &block) ⇒ Object

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



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/ajax_scaffold_plugin.rb', line 465

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[:locals] ||= {}
    options[:use_full_path] = options[:use_full_path].nil? ? true : options[:use_full_path]

    if options[:file]
      render_file(options[:file], options[:use_full_path], options[:locals])
    elsif options[:partial] && options[:collection]
      partial = parse_partial_path(options[:partial])
      render_partial_collection(partial, options[:collection], options[:spacer_template], options[:locals])
    elsif options[:partial]
      partial = parse_partial_path(options[:partial])
      render_partial(partial, ActionView::Base::ObjectWrapper.new(options[:object]), options[:locals])
    elsif options[:inline]
      render_template(options[:type] || :rhtml, options[:inline], nil, options[:locals] || {})
    end
  end
end