react-rails 1.3.3 → 1.4.2
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/README.md +23 -4
- data/lib/assets/react-source/development/react-server.js +19677 -0
- data/lib/assets/react-source/development/react.js +19639 -19602
- data/lib/assets/react-source/development-with-addons/react-server.js +21691 -0
- data/lib/assets/react-source/development-with-addons/react.js +21681 -21642
- data/lib/assets/react-source/production/react-server.js +18 -0
- data/lib/assets/react-source/production/react.js +18 -16
- data/lib/assets/react-source/production-with-addons/react-server.js +19 -0
- data/lib/assets/react-source/production-with-addons/react.js +19 -18
- data/lib/generators/react/component_generator.rb +17 -4
- data/lib/generators/templates/component.js.jsx.coffee +18 -0
- data/lib/react/jsx/processor.rb +9 -0
- data/lib/react/jsx.rb +1 -0
- data/lib/react/rails/controller_renderer.rb +1 -1
- data/lib/react/rails/engine.rb +6 -1
- data/lib/react/rails/version.rb +1 -1
- data/lib/react/server_rendering/exec_js_renderer.rb +2 -1
- data/lib/react/server_rendering/sprockets_renderer.rb +1 -1
- metadata +8 -2
@@ -51,9 +51,14 @@ module React
|
|
51
51
|
:banner => "field[:type] field[:type] ..."
|
52
52
|
|
53
53
|
class_option :es6,
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
type: :boolean,
|
55
|
+
default: false,
|
56
|
+
desc: 'Output es6 class based component'
|
57
|
+
|
58
|
+
class_option :coffee,
|
59
|
+
type: :boolean,
|
60
|
+
default: false,
|
61
|
+
desc: 'Output coffeescript based component'
|
57
62
|
|
58
63
|
REACT_PROP_TYPES = {
|
59
64
|
"node" => 'React.PropTypes.node',
|
@@ -85,7 +90,15 @@ module React
|
|
85
90
|
}
|
86
91
|
|
87
92
|
def create_component_file
|
88
|
-
extension =
|
93
|
+
extension = case
|
94
|
+
when options[:es6]
|
95
|
+
'es6.jsx'
|
96
|
+
when options[:coffee]
|
97
|
+
'js.jsx.coffee'
|
98
|
+
else
|
99
|
+
'js.jsx'
|
100
|
+
end
|
101
|
+
|
89
102
|
file_path = File.join('app/assets/javascripts/components', "#{file_name}.#{extension}")
|
90
103
|
template("component.#{extension}", file_path)
|
91
104
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class @<%= file_name.camelize %> extends React.Component
|
2
|
+
<% if attributes.size > 0 -%>
|
3
|
+
@propTypes =
|
4
|
+
<% attributes.each do |attribute| -%>
|
5
|
+
<%= attribute[:name].camelize(:lower) %>: <%= attribute[:type] %>
|
6
|
+
<% end -%>
|
7
|
+
|
8
|
+
<% end -%>
|
9
|
+
render: ->
|
10
|
+
<% if attributes.size > 0 -%>
|
11
|
+
`<div>
|
12
|
+
<% attributes.each do |attribute| -%>
|
13
|
+
<div><%= attribute[:name].titleize %>: {this.props.<%= attribute[:name].camelize(:lower) %>}</div>
|
14
|
+
<% end -%>
|
15
|
+
</div>`
|
16
|
+
<% else -%>
|
17
|
+
`<div />`
|
18
|
+
<% end -%>
|
data/lib/react/jsx.rb
CHANGED
@@ -12,7 +12,7 @@ class React::Rails::ControllerRenderer
|
|
12
12
|
|
13
13
|
def call(name, options, &block)
|
14
14
|
props = options.fetch(:props, {})
|
15
|
-
options = options.slice(:data, :tag).merge(prerender: true)
|
15
|
+
options = options.slice(:data, :aria, :tag, :class, :id).merge(prerender: true)
|
16
16
|
react_component(name, props, options, &block)
|
17
17
|
end
|
18
18
|
end
|
data/lib/react/rails/engine.rb
CHANGED
@@ -3,7 +3,12 @@ module React
|
|
3
3
|
class Engine < ::Rails::Engine
|
4
4
|
initializer "react_rails.setup_engine", :group => :all do |app|
|
5
5
|
sprockets_env = app.assets || Sprockets # Sprockets 3.x expects this in a different place
|
6
|
-
|
6
|
+
if Gem::Version.new(Sprockets::VERSION) >= Gem::Version.new("3.0.0")
|
7
|
+
sprockets_env.register_mime_type("application/jsx", extensions: [".jsx", ".js.jsx"])
|
8
|
+
sprockets_env.register_transformer("application/jsx", "application/javascript", React::JSX::Processor)
|
9
|
+
else
|
10
|
+
sprockets_env.register_engine(".jsx", React::JSX::Template)
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
data/lib/react/rails/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# A bare-bones renderer for React.js + Exec.js
|
2
|
+
# - Depends on global ReactDOMServer in the ExecJS context
|
2
3
|
# - No Rails dependency
|
3
4
|
# - No browser concerns
|
4
5
|
module React
|
@@ -14,7 +15,7 @@ module React
|
|
14
15
|
js_code = <<-JS
|
15
16
|
(function () {
|
16
17
|
#{before_render(component_name, props, prerender_options)}
|
17
|
-
var result =
|
18
|
+
var result = ReactDOMServer.#{render_function}(React.createElement(#{component_name}, #{props}));
|
18
19
|
#{after_render(component_name, props, prerender_options)}
|
19
20
|
return result;
|
20
21
|
})()
|
@@ -7,7 +7,7 @@ module React
|
|
7
7
|
class SprocketsRenderer < ExecJSRenderer
|
8
8
|
def initialize(options={})
|
9
9
|
@replay_console = options.fetch(:replay_console, true)
|
10
|
-
filenames = options.fetch(:files, ["react.js", "components.js"])
|
10
|
+
filenames = options.fetch(:files, ["react-server.js", "components.js"])
|
11
11
|
js_code = CONSOLE_POLYFILL.dup
|
12
12
|
|
13
13
|
filenames.each do |filename|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul O’Shannessy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -257,16 +257,22 @@ extra_rdoc_files: []
|
|
257
257
|
files:
|
258
258
|
- lib/assets/javascripts/JSXTransformer.js
|
259
259
|
- lib/assets/javascripts/react_ujs.js.erb
|
260
|
+
- lib/assets/react-source/development/react-server.js
|
260
261
|
- lib/assets/react-source/development/react.js
|
262
|
+
- lib/assets/react-source/development-with-addons/react-server.js
|
261
263
|
- lib/assets/react-source/development-with-addons/react.js
|
264
|
+
- lib/assets/react-source/production/react-server.js
|
262
265
|
- lib/assets/react-source/production/react.js
|
266
|
+
- lib/assets/react-source/production-with-addons/react-server.js
|
263
267
|
- lib/assets/react-source/production-with-addons/react.js
|
264
268
|
- lib/generators/react/component_generator.rb
|
265
269
|
- lib/generators/react/install_generator.rb
|
266
270
|
- lib/generators/templates/component.es6.jsx
|
267
271
|
- lib/generators/templates/component.js.jsx
|
272
|
+
- lib/generators/templates/component.js.jsx.coffee
|
268
273
|
- lib/react/jsx/babel_transformer.rb
|
269
274
|
- lib/react/jsx/jsx_transformer.rb
|
275
|
+
- lib/react/jsx/processor.rb
|
270
276
|
- lib/react/jsx/template.rb
|
271
277
|
- lib/react/jsx.rb
|
272
278
|
- lib/react/rails/asset_variant.rb
|