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 +4 -4
- data/lib/react/rails/controller_renderer.rb +42 -0
- data/lib/react/rails/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31a24294adf6047b7445ebf48130aa999011bdf7020a4904b23716ba3d350d37
|
4
|
+
data.tar.gz: 0ae79e96ff0636553217907da6b88f93e1361e3e8ed0dd8babc948cf25157340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/react/rails/version.rb
CHANGED
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.
|
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
|