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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59c0e2d224ae087eecda65188c20d2bfcff98e7b
|
4
|
+
data.tar.gz: e83257d235e950105dfc5a6367abcbcb56075508
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9c0e1194927b94f6b618b2ffc33f41feb8d609f4468cba49f9d143a86b5b2ac7383a9109ea3ebc37e85e3a9ccd562b80bef87a024fee7a45ce2fcb32c4ba3f8
|
7
|
+
data.tar.gz: ffb97409f51d621879ebf3fad89bdcf3f0e972a63403b497ee12017e5665ad91a7729b2daa63d85ba94dbc82ae28e6bdae6bff68b9d2242b799a3ff76b150bb6
|
data/README.md
CHANGED
@@ -19,12 +19,14 @@ in your Ruby on Rails (3.2+) application. `react-rails` can:
|
|
19
19
|
- [Generate components](#component-generator) with a Rails generator
|
20
20
|
- [Be extended](#extending-react-rails) with custom renderers, transformers and view helpers
|
21
21
|
|
22
|
+
Just getting started with React? Make sure to check out the [Getting Started] (https://facebook.github.io/react/docs/getting-started.html) guide.
|
23
|
+
|
22
24
|
## Installation
|
23
25
|
|
24
26
|
Add `react-rails` to your gemfile:
|
25
27
|
|
26
28
|
```ruby
|
27
|
-
gem 'react-rails', '~> 1.
|
29
|
+
gem 'react-rails', '~> 1.4.0'
|
28
30
|
```
|
29
31
|
|
30
32
|
Next, run the installation script:
|
@@ -194,7 +196,7 @@ MyApp::Application.configure do
|
|
194
196
|
config.react.server_renderer_timeout ||= 20 # seconds
|
195
197
|
config.react.server_renderer = React::ServerRendering::SprocketsRenderer
|
196
198
|
config.react.server_renderer_options = {
|
197
|
-
files: ["react.js", "components.js"], # files to load for prerendering
|
199
|
+
files: ["react-server.js", "components.js"], # files to load for prerendering
|
198
200
|
replay_console: true, # if true, console.* will be replayed client-side
|
199
201
|
}
|
200
202
|
end
|
@@ -212,13 +214,14 @@ Components can also be prerendered directly from a controller action with the cu
|
|
212
214
|
class TodoController < ApplicationController
|
213
215
|
def index
|
214
216
|
@todos = Todo.all
|
215
|
-
render component: 'TodoList', props: { todos: @todos }, tag: 'span'
|
217
|
+
render component: 'TodoList', props: { todos: @todos }, tag: 'span', class: 'todo'
|
216
218
|
end
|
217
219
|
end
|
218
220
|
```
|
219
221
|
|
220
222
|
This custom renderer behaves the same as a normal view renderer and accepts the usual arguments - `content_type`, `layout`, `location` and `status`.
|
221
|
-
By default, your current layout will be used and the component, rather than a view, will be rendered in place of `yield`.
|
223
|
+
By default, your current layout will be used and the component, rather than a view, will be rendered in place of `yield`. Custom data-* attributes
|
224
|
+
can be passed like `data: {remote: true}`.
|
222
225
|
|
223
226
|
### Component generator
|
224
227
|
|
@@ -268,6 +271,14 @@ For example:
|
|
268
271
|
rails generate react:component Label label:string --es6
|
269
272
|
```
|
270
273
|
|
274
|
+
**--coffee** : Generate the component using CoffeeScript syntax
|
275
|
+
|
276
|
+
For example:
|
277
|
+
|
278
|
+
```shell
|
279
|
+
rails generate react:component Label label:string --coffee
|
280
|
+
```
|
281
|
+
|
271
282
|
#### Arguments
|
272
283
|
|
273
284
|
The generator can use the following arguments to create basic propTypes:
|
@@ -323,6 +334,14 @@ Component = React.createClass
|
|
323
334
|
`<ExampleComponent videos={this.props.videos} />`
|
324
335
|
```
|
325
336
|
|
337
|
+
Alternatively, the newer ES6 style class based syntax can be used like this:
|
338
|
+
|
339
|
+
```coffee
|
340
|
+
class Component extends React.Component
|
341
|
+
render: ->
|
342
|
+
`<ExampleComponent videos={this.props.videos} />`
|
343
|
+
```
|
344
|
+
|
326
345
|
## Extending `react-rails`
|
327
346
|
|
328
347
|
You can extend some of the core functionality of `react-rails` by injecting new implementations during configuration.
|