Module: ComponentParty::ActionView::Renderer

Defined in:
lib/component_party/action_view/renderer.rb

Instance Method Summary collapse

Instance Method Details

#normalize_component_path!(_context, options) ⇒ void

An example of options argumento passed by Rails are { :prefixes=>["devise/sessions", "devise", "application"], :template=>"new", :layout=> a Proc } rubocop:disable Metrics/LineLength



26
27
28
29
30
31
32
# File 'lib/component_party/action_view/renderer.rb', line 26

def normalize_component_path!(_context, options)
  if options[:component] == true
    options[:component] = Pathname.new(ComponentParty.configuration.component_folder_for_actions).join(options[:prefixes].first.to_s, options[:template]).to_s
  else
    options[:component]
  end
end

#normalize_data_for_component_rendering!(context, options) ⇒ void



14
15
16
17
# File 'lib/component_party/action_view/renderer.rb', line 14

def normalize_data_for_component_rendering!(context, options)
  normalize_component_path!(context, options)
  context.instance_variable_set('@current_component_path', options[:component])
end

#render(context, options) ⇒ void



5
6
7
8
9
10
11
12
# File 'lib/component_party/action_view/renderer.rb', line 5

def render(context, options)
  if options.key?(:component)
    normalize_data_for_component_rendering!(context, options)
    ComponentParty::ActionView::ComponentRenderer.new(lookup_context, options[:component]).render(context, options)
  else
    super(context, options)
  end
end