react-rails-stupid 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36c0d332c7c60d76199038cc0549b7f874b557d3720e29500ef24fbad6a173d1
4
- data.tar.gz: 42bda8a0f4c8630c75ad4ac9b11676592763b99fc828fd3ce9b5d9ba888e821c
3
+ metadata.gz: 31a24294adf6047b7445ebf48130aa999011bdf7020a4904b23716ba3d350d37
4
+ data.tar.gz: 0ae79e96ff0636553217907da6b88f93e1361e3e8ed0dd8babc948cf25157340
5
5
  SHA512:
6
- metadata.gz: ad30f5902b655c024bc98484a85badb72404403a9d547e266a30ce8c9bac90529c9a3d1caaa182c06fe5445f78e9a279960daa5d9afbfb7c2e58244498aa0a64
7
- data.tar.gz: 46aa0266e8566689644a458ede3cf8747fa398098bffc07f7667ed1dad780614039ff315920809f29f6dde332d7a989d0e43ded169b3d4940f0c5a20b44a2157
6
+ metadata.gz: a46ab68d7539ba59949b772b0d82397fa036333b043339d53986a4cf5270171f4572bb35f4c6b8890ab2f2e57c626ee8d09dd07c9cda8f061519c2596462df4b
7
+ data.tar.gz: dd9a517cd7a8adb99e87078d3401e06ae93b100febbd2f4855b420d5f13198fd8b922693cc4bcd0db1d7ed105b563761597442991fa7f1212164c69f38716f01
@@ -0,0 +1,42 @@
1
+ module React
2
+ module Rails
3
+ # A renderer class suitable for `ActionController::Renderers`.
4
+ # It is associated to `:component` in the Railtie.
5
+ #
6
+ # It is prerendered by default with {React::ServerRendering}.
7
+ # Set options[:prerender] to `false` to disable prerendering.
8
+ #
9
+ # @example Rendering a component from a controller
10
+ # class TodosController < ApplicationController
11
+ # def index
12
+ # @todos = Todo.all
13
+ # render component: 'TodoList', props: { todos: @todos }, tag: 'span', class: 'todo'
14
+ # end
15
+ # end
16
+ class ControllerRenderer
17
+ include React::Rails::ViewHelper
18
+ include ActionView::Helpers::TagHelper
19
+ include ActionView::Helpers::TextHelper
20
+
21
+ attr_accessor :output_buffer
22
+
23
+ def initialize(options={})
24
+ controller = options[:controller]
25
+ @__react_component_helper = controller.__react_component_helper
26
+ end
27
+
28
+ # @return [String] HTML for `component_name` with `options[:props]`
29
+ def call(component_name, options, &block)
30
+ props = options.fetch(:props, {})
31
+ options = default_options.merge(options.slice(:data, :aria, :tag, :class, :id, :prerender, :camelize_props))
32
+ react_component(component_name, props, options, &block)
33
+ end
34
+
35
+ private
36
+
37
+ def default_options
38
+ { prerender: true }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -2,6 +2,6 @@ module React
2
2
  module Rails
3
3
  # If you change this, make sure to update VERSIONS.md
4
4
  # And the version hint in README.md, if needed
5
- VERSION = '1.5.3'
5
+ VERSION = '1.5.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-rails-stupid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-x-
@@ -64,6 +64,7 @@ files:
64
64
  - lib/react-rails-stupid.rb
65
65
  - lib/react/rails.rb
66
66
  - lib/react/rails/component_mount.rb
67
+ - lib/react/rails/controller_renderer.rb
67
68
  - lib/react/rails/railtie.rb
68
69
  - lib/react/rails/version.rb
69
70
  - lib/react/rails/view_helper.rb