Class: React::Rails::ControllerRenderer
- Inherits:
-
Object
- Object
- React::Rails::ControllerRenderer
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, ViewHelper
- Defined in:
- lib/react/rails/controller_renderer.rb
Overview
A renderer class suitable for ‘ActionController::Renderers`. It is associated to `:component` in the Railtie.
It is prerendered with ServerRendering.
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
-
#call(component_name, options, &block) ⇒ String
Prerendered HTML for ‘component_name` with `options`.
-
#initialize(options = {}) ⇒ ControllerRenderer
constructor
A new instance of ControllerRenderer.
Methods included from ViewHelper
Constructor Details
#initialize(options = {}) ⇒ ControllerRenderer
Returns a new instance of ControllerRenderer.
22 23 24 25 |
# File 'lib/react/rails/controller_renderer.rb', line 22 def initialize(={}) controller = [:controller] @__react_component_helper = controller.__react_component_helper end |
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
20 21 22 |
# File 'lib/react/rails/controller_renderer.rb', line 20 def output_buffer @output_buffer end |
Instance Method Details
#call(component_name, options, &block) ⇒ String
Returns Prerendered HTML for ‘component_name` with `options`.
28 29 30 31 32 |
# File 'lib/react/rails/controller_renderer.rb', line 28 def call(component_name, , &block) props = .fetch(:props, {}) = .slice(:data, :aria, :tag, :class, :id).merge(prerender: true) react_component(component_name, props, , &block) end |