Module: Hiccdown::CustomViewRendering

Extended by:
ActiveSupport::Concern
Defined in:
lib/hiccdown/railtie.rb

Instance Method Summary collapse

Instance Method Details

#custom_default_renderObject


65
66
67
# File 'lib/hiccdown/railtie.rb', line 65

def custom_default_render
  render_helper_method(params[:action])
end

#custom_render(*args) ⇒ Object


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/hiccdown/railtie.rb', line 44

def custom_render *args
  options = args.extract_options!

  # Implicit rendering
  if options.empty? && args.empty?
    custom_default_render
  # Explicit rendering, such as `render :show` or `render action: :show`,
  # but not partials or files (which would include a /)
  elsif options.key?(:action) || args.first.is_a?(Symbol) || (args.first.is_a?(String) && !args.first.include?('/'))
    action_name = options[:action] || args.first.to_s
    render_helper_method(action_name, options)
  # When a template is given but doesn’t exist. Useful for gems like High Voltage
  elsif options.key?(:template) && !view_context.lookup_context.template_exists?(options[:template])
    action_name = options[:template].split('/').last
    render_helper_method(action_name, options)
  # Partials, files and all other cases
  else
    original_render(*args, options)
  end
end