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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a37b2fda991f6134211a91c1aca89ce539a9dddd
4
- data.tar.gz: f0927633df2726414e86ba931c323d6fd25038d6
3
+ metadata.gz: 7f1b7d12ce69670b3e7e037d28aecc1401350e75
4
+ data.tar.gz: 03d40c296e959ad85e2f539055036ee0273e3fc1
5
5
  SHA512:
6
- metadata.gz: 84ff0c3e94a1fff7b5893d0c03fdc8cba3efd40cbbbe09ea288b825534d52020fd65ff80be2e040d9eead3d0f5d2eab48847b61d2a99ce73b98d38587ba3c715
7
- data.tar.gz: dbe4bd42c1109d45fbde205e20fa11d2e173d6ef23c95506b080a8ba028eb6e5389e80cb61d39f05f7ac76a00873907174f3dd7805871f46c2f86800d2dfca66
6
+ metadata.gz: f6f6b663282dd9b93aaa29df3448ad26669e9b3c2ef3f9a1e6d06d5aa7bb77889a90eb1c2dd9f13f693db24104a56430bb3c582b64c9610642fd8800eaf3ad1a
7
+ data.tar.gz: 9c6dfe03fa58428e87e2b0d769ce6ef63789df2323387c081eb8309e880003cc288b248d165e1304ac691f212230df132438ddcb83612446a0e52c14d2b2ac31
data/Gemfile CHANGED
@@ -40,3 +40,4 @@ gem "chromedriver-helper"
40
40
  gem "launchy"
41
41
  gem "poltergeist"
42
42
  gem "selenium-webdriver"
43
+ gem "yajl-ruby"
@@ -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
- content_tag(:div,
109
- "",
110
- class: "js-react-on-rails-component",
111
- style: options.style,
112
- data: options.data)
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(:div,
239
- "",
240
- id: "js-react-on-rails-context",
241
- style: ReactOnRails.configuration.skip_display_none ? nil : "display:none",
242
- data: data)
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(:div,
248
- "",
249
- class: "js-react-on-rails-store",
250
- style: ReactOnRails.configuration.skip_display_none ? nil : "display:none",
251
- data: redux_store_data)
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
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ReactOnRails
3
- VERSION = "6.5.1".freeze
3
+ VERSION = "6.6.0.alpha.1".freeze
4
4
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "6.5.1",
3
+ "version": "6.6.0-alpha.1",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
@@ -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.5.1
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: '0'
464
+ version: 1.3.1
451
465
  requirements: []
452
466
  rubyforge_project:
453
467
  rubygems_version: 2.6.8