Module: Frails::Monkey::ActionView::Renderer

Defined in:
lib/frails/monkey/action_view/renderer.rb

Instance Method Summary collapse

Instance Method Details

#render_component(context, options, &block) ⇒ Object

Direct access to partial rendering.



18
19
20
# File 'lib/frails/monkey/action_view/renderer.rb', line 18

def render_component(context, options, &block) #:nodoc:
  render_component_to_object(context, options, &block).body
end

#render_component_to_object(context, options, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/frails/monkey/action_view/renderer.rb', line 22

def render_component_to_object(context, options, &block)
  component = options[:component].to_s

  result = if Rails.root.join('app', 'components', component, 'index.entry.jsx').exist?
             Frails::Component::ReactComponentRenderer.new.render(context, options, &block)
           else
             options[:partial] = "#{component}/index"
             Frails::Component::ComponentRenderer.new(@lookup_context)
                                                 .render(context, options, &block)
           end

  ::ActionView::AbstractRenderer::RenderedTemplate.new result, nil, nil
end

#render_to_object(context, options) ⇒ Object

:nodoc:



7
8
9
10
11
12
13
14
15
# File 'lib/frails/monkey/action_view/renderer.rb', line 7

def render_to_object(context, options) # :nodoc:
  if options.key?(:partial)
    render_partial_to_object(context, options)
  elsif options.key?(:component)
    render_component_to_object(context, options)
  else
    render_template_to_object(context, options)
  end
end