react_webpack_rails 0.0.5 → 0.1.0
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/.babelrc +3 -0
- data/.gitignore +3 -0
- data/.npmignore +1 -0
- data/.travis.yml +37 -3
- data/CHANGELOG.md +56 -0
- data/README.md +6 -0
- data/Rakefile +42 -6
- data/bin/setup +2 -0
- data/docs/README.md +10 -9
- data/docs/api.md +103 -99
- data/js/.eslintrc +12 -0
- data/js/src/env.js +1 -0
- data/js/src/index.js +30 -0
- data/js/src/integrations-manager.js +22 -0
- data/js/src/integrations/react-router.js +48 -0
- data/js/src/integrations/react.js +49 -0
- data/js/src/nodes.js +51 -0
- data/js/src/version.js +1 -0
- data/js/test/env.spec.js +10 -0
- data/js/test/integrations-manager.spec.js +38 -0
- data/js/test/integrations/react-router.spec.js +133 -0
- data/js/test/integrations/react.spec.js +96 -0
- data/js/test/nodes.spec.js +121 -0
- data/lib/assets/javascripts/react_integration.js.erb +74 -155
- data/lib/generators/react_webpack_rails/templates/.babelrc +1 -1
- data/lib/generators/react_webpack_rails/templates/karma.conf.js +1 -1
- data/lib/generators/react_webpack_rails/templates/package.json.erb +9 -3
- data/lib/generators/react_webpack_rails/templates/react/index.js.erb +4 -6
- data/lib/generators/react_webpack_rails/templates/webpack.config.js +1 -1
- data/lib/react_webpack_rails/railtie.rb +5 -0
- data/lib/react_webpack_rails/version.rb +1 -1
- data/lib/react_webpack_rails/view_helpers.rb +24 -12
- data/package.json +49 -0
- metadata +19 -4
@@ -1,21 +1,33 @@
|
|
1
1
|
module ReactWebpackRails
|
2
2
|
module ViewHelpers
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
html_tag = html_options[:tag] || :div
|
12
|
-
html_options.except!(:tag)
|
13
|
-
|
3
|
+
def react_element(integration_name, payload = {}, html_options = {}, &block)
|
4
|
+
data = {
|
5
|
+
integration_name: integration_name,
|
6
|
+
payload: payload,
|
7
|
+
react_element: true
|
8
|
+
}
|
9
|
+
html_options = html_options.merge(data: data)
|
10
|
+
html_tag = html_options.delete(:tag) || :div
|
14
11
|
content_tag(html_tag, '', html_options, &block)
|
15
12
|
end
|
16
13
|
|
14
|
+
def react_component(name, props = {}, options = { ssr: false })
|
15
|
+
props = camelize_props_key(props) if Rails.application.config.react.camelize_props
|
16
|
+
react_element('react-component', { props: props, name: name }, options)
|
17
|
+
end
|
18
|
+
|
17
19
|
def react_router(name)
|
18
|
-
|
20
|
+
react_element('react-router', name: name)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def camelize_props_key(props)
|
26
|
+
return props unless props.is_a?(Hash)
|
27
|
+
props.each_with_object({}) do |h, (k, v)|
|
28
|
+
h[k.to_s.camelize(:lower)] = v.is_a?(Hash) ? camelize_props_key(v) : v
|
29
|
+
h
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
21
33
|
end
|
data/package.json
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"name": "react-webpack-rails",
|
3
|
+
"version": "0.1.0",
|
4
|
+
"description": "Js part of react_webpack_rails - webpack based React & Rails integration.",
|
5
|
+
"main": "js/lib/index.js",
|
6
|
+
"files": [
|
7
|
+
"js/lib"
|
8
|
+
],
|
9
|
+
"scripts": {
|
10
|
+
"compile": "babel --presets es2015 -d js/lib/ js/src/",
|
11
|
+
"prepublish": "npm run compile",
|
12
|
+
"test": "mocha js/test --ui bdd --recursive --require babel-core/register"
|
13
|
+
},
|
14
|
+
"repository": {
|
15
|
+
"type": "git",
|
16
|
+
"url": "git+https://github.com/netguru/react_webpack_rails.git"
|
17
|
+
},
|
18
|
+
"keywords": [
|
19
|
+
"react",
|
20
|
+
"rails",
|
21
|
+
"webpack",
|
22
|
+
"react_webpack_rails"
|
23
|
+
],
|
24
|
+
"author": "Rafał Gawlik",
|
25
|
+
"license": "MIT",
|
26
|
+
"bugs": {
|
27
|
+
"url": "https://github.com/netguru/react_webpack_rails/issues"
|
28
|
+
},
|
29
|
+
"homepage": "https://github.com/netguru/react_webpack_rails#readme",
|
30
|
+
"peerDependencies": {
|
31
|
+
"react": "^0.14.0",
|
32
|
+
"react-dom": "^0.14.0"
|
33
|
+
},
|
34
|
+
"dependencies": {
|
35
|
+
"babel-polyfill": "^6.3.0"
|
36
|
+
},
|
37
|
+
"devDependencies": {
|
38
|
+
"babel-cli": "^6.4.0",
|
39
|
+
"babel-core": "^6.4.0",
|
40
|
+
"babel-preset-es2015": "^6.3.0",
|
41
|
+
"babel-preset-react": "^6.3.0",
|
42
|
+
"eslint": "^1.10.3",
|
43
|
+
"eslint-config-airbnb": "^3.1.0",
|
44
|
+
"eslint-plugin-react": "^3.15.0",
|
45
|
+
"expect": "^1.13.4",
|
46
|
+
"history": "^1.17.0",
|
47
|
+
"mocha": "^2.3.4"
|
48
|
+
}
|
49
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_webpack_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafał Gawlik
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -75,7 +75,9 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
+
- ".babelrc"
|
78
79
|
- ".gitignore"
|
80
|
+
- ".npmignore"
|
79
81
|
- ".rspec"
|
80
82
|
- ".travis.yml"
|
81
83
|
- CHANGELOG.md
|
@@ -88,6 +90,19 @@ files:
|
|
88
90
|
- docs/README.md
|
89
91
|
- docs/api.md
|
90
92
|
- docs/deployment.md
|
93
|
+
- js/.eslintrc
|
94
|
+
- js/src/env.js
|
95
|
+
- js/src/index.js
|
96
|
+
- js/src/integrations-manager.js
|
97
|
+
- js/src/integrations/react-router.js
|
98
|
+
- js/src/integrations/react.js
|
99
|
+
- js/src/nodes.js
|
100
|
+
- js/src/version.js
|
101
|
+
- js/test/env.spec.js
|
102
|
+
- js/test/integrations-manager.spec.js
|
103
|
+
- js/test/integrations/react-router.spec.js
|
104
|
+
- js/test/integrations/react.spec.js
|
105
|
+
- js/test/nodes.spec.js
|
91
106
|
- lib/assets/javascripts/react_integration.js.erb
|
92
107
|
- lib/generators/react_webpack_rails/install_generator.rb
|
93
108
|
- lib/generators/react_webpack_rails/templates/.babelrc
|
@@ -107,6 +122,7 @@ files:
|
|
107
122
|
- lib/react_webpack_rails/railtie.rb
|
108
123
|
- lib/react_webpack_rails/version.rb
|
109
124
|
- lib/react_webpack_rails/view_helpers.rb
|
125
|
+
- package.json
|
110
126
|
- react_webpack_rails.gemspec
|
111
127
|
homepage: https://github.com/netguru/react_webpack_rails
|
112
128
|
licenses:
|
@@ -128,9 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
144
|
version: '0'
|
129
145
|
requirements: []
|
130
146
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.4.5
|
147
|
+
rubygems_version: 2.4.5.1
|
132
148
|
signing_key:
|
133
149
|
specification_version: 4
|
134
150
|
summary: React and Rails integration done with webpack
|
135
151
|
test_files: []
|
136
|
-
has_rdoc:
|