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 by default with ServerRendering. Set options to ‘false` to disable prerendering.
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
-
#call(component_name, options, &block) ⇒ String
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.
23 24 25 26 |
# File 'lib/react/rails/controller_renderer.rb', line 23 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.
21 22 23 |
# File 'lib/react/rails/controller_renderer.rb', line 21 def output_buffer @output_buffer end |
Instance Method Details
#call(component_name, options, &block) ⇒ String
Returns HTML for ‘component_name` with `options`.
29 30 31 32 33 |
# File 'lib/react/rails/controller_renderer.rb', line 29 def call(component_name, , &block) props = .fetch(:props, {}) = .merge(.slice(:data, :aria, :tag, :class, :id, :prerender, :camelize_props)) react_component(component_name, props, , &block) end |