react_on_rails 6.5.1 → 6.6.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/app/helpers/react_on_rails_helper.rb +27 -20
- data/lib/react_on_rails/version.rb +1 -1
- data/package.json +1 -1
- data/react_on_rails.gemspec +2 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f1b7d12ce69670b3e7e037d28aecc1401350e75
|
4
|
+
data.tar.gz: 03d40c296e959ad85e2f539055036ee0273e3fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f6b663282dd9b93aaa29df3448ad26669e9b3c2ef3f9a1e6d06d5aa7bb77889a90eb1c2dd9f13f693db24104a56430bb3c582b64c9610642fd8800eaf3ad1a
|
7
|
+
data.tar.gz: 9c6dfe03fa58428e87e2b0d769ce6ef63789df2323387c081eb8309e880003cc288b248d165e1304ac691f212230df132438ddcb83612446a0e52c14d2b2ac31
|
data/Gemfile
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
require "react_on_rails/prerender_error"
|
7
7
|
require "addressable/uri"
|
8
8
|
require "react_on_rails/utils"
|
9
|
+
require "yajl"
|
9
10
|
|
10
11
|
module ReactOnRailsHelper
|
11
12
|
include ReactOnRails::Utils::Required
|
@@ -103,13 +104,13 @@ module ReactOnRailsHelper
|
|
103
104
|
|
104
105
|
# Setup the page_loaded_js, which is the same regardless of prerendering or not!
|
105
106
|
# The reason is that React is smart about not doing extra work if the server rendering did its job.
|
106
|
-
|
107
|
+
|
107
108
|
component_specification_tag =
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
109
|
+
content_tag(:div,
|
110
|
+
"",
|
111
|
+
class: "js-react-on-rails-component",
|
112
|
+
style: options.style,
|
113
|
+
data: options.data)
|
113
114
|
|
114
115
|
# Create the HTML rendering part
|
115
116
|
result = server_rendered_react_component_html(options.props, options.name, options.dom_id,
|
@@ -174,7 +175,7 @@ module ReactOnRailsHelper
|
|
174
175
|
end
|
175
176
|
|
176
177
|
def sanitized_props_string(props)
|
177
|
-
props.is_a?(String) ? json_escape(props) : props.to_json
|
178
|
+
props.is_a?(String) ? ERB::Util.json_escape(props) : props.to_json
|
178
179
|
end
|
179
180
|
|
180
181
|
# Helper method to take javascript expression and returns the output from evaluating it.
|
@@ -225,30 +226,36 @@ module ReactOnRailsHelper
|
|
225
226
|
|
226
227
|
private
|
227
228
|
|
229
|
+
def json_safe_and_pretty(something)
|
230
|
+
if defined?(Rails) && Rails.env.development?
|
231
|
+
ERB::Util.json_escape(JSON.pretty_generate(something.as_json))
|
232
|
+
else
|
233
|
+
ERB::Util.json_escape(something.to_json)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
228
237
|
# prepend the rails_context if not yet applied
|
229
238
|
def prepend_render_rails_context(render_value)
|
230
239
|
return render_value if @rendered_rails_context
|
231
240
|
|
232
|
-
data =
|
233
|
-
rails_context: rails_context(server_side: false)
|
234
|
-
}
|
241
|
+
data = rails_context(server_side: false)
|
235
242
|
|
236
243
|
@rendered_rails_context = true
|
237
244
|
|
238
|
-
rails_context_content = content_tag(:
|
239
|
-
"",
|
240
|
-
|
241
|
-
|
242
|
-
|
245
|
+
rails_context_content = content_tag(:script,
|
246
|
+
"#{json_safe_and_pretty(data)}".html_safe,
|
247
|
+
type: 'application/json',
|
248
|
+
id: 'js-react-on-rails-context')
|
249
|
+
|
243
250
|
"#{rails_context_content}\n#{render_value}".html_safe
|
244
251
|
end
|
245
252
|
|
246
253
|
def render_redux_store_data(redux_store_data)
|
247
|
-
result = content_tag(:
|
248
|
-
"",
|
249
|
-
|
250
|
-
|
251
|
-
|
254
|
+
result = content_tag(:script,
|
255
|
+
"#{json_safe_and_pretty(redux_store_data[:props])}".html_safe,
|
256
|
+
type: 'application/json',
|
257
|
+
'data-js-react-on-rails-store' => redux_store_data[:store_name].html_safe)
|
258
|
+
|
252
259
|
prepend_render_rails_context(result)
|
253
260
|
end
|
254
261
|
|
data/package.json
CHANGED
data/react_on_rails.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency "rainbow", "~> 2.1"
|
27
27
|
s.add_dependency "rails", ">= 3.2"
|
28
28
|
s.add_dependency "addressable"
|
29
|
+
s.add_dependency "yajl-ruby"
|
29
30
|
|
30
31
|
s.add_development_dependency "bundler", "~> 1.10"
|
31
32
|
s.add_development_dependency "rake", "~> 10.0"
|
@@ -42,4 +43,5 @@ Gem::Specification.new do |s|
|
|
42
43
|
s.add_development_dependency "binding_of_caller"
|
43
44
|
s.add_development_dependency "awesome_print"
|
44
45
|
s.add_development_dependency "gem-release"
|
46
|
+
|
45
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0.alpha.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yajl-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -445,9 +459,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
445
459
|
version: 2.0.0
|
446
460
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
447
461
|
requirements:
|
448
|
-
- - "
|
462
|
+
- - ">"
|
449
463
|
- !ruby/object:Gem::Version
|
450
|
-
version:
|
464
|
+
version: 1.3.1
|
451
465
|
requirements: []
|
452
466
|
rubyforge_project:
|
453
467
|
rubygems_version: 2.6.8
|