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)
  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
# 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 Frails.components_path.join(component, 'index.entry.jsx').exist?
             Frails::Component::ReactRenderer.new.render(context, options, &block)
           else
             Frails::Component::Renderer.new(@lookup_context)
                                        .render(context, options, &block)
           end

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

#render_to_object(context, options) ⇒ Object



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)
  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