render-react 0.0.1 → 0.0.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/lib/render/react.rb +6 -8
- data/lib/render/react/compiler.rb +2 -0
- data/lib/render/react/transpiler.rb +3 -1
- data/lib/render/react/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 034cfe68457045e81b4c578ca14fa5ba692c7dc0
|
4
|
+
data.tar.gz: f9d63c8fa6b963ac7632a4c3f9a981647bba64f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b26d92e8ad3f2a5fad6e661cfbd833108ca796c53d7a2d8910dcc5bb519989ada3de6a861a98d9c1458e345b0f78e12ad8a2adb287ffaef5992e4e46969d7c28
|
7
|
+
data.tar.gz: 223d10391d0462ac36791cbd1a988a3e4ae48b36a8c7aeb1021a794191e3282e00f216ed7aaa94b60cbabe417a624930fd9e8773bdf92149ae0ea351eb90a42e
|
data/lib/render/react.rb
CHANGED
@@ -9,15 +9,13 @@ require 'render/react/version'
|
|
9
9
|
|
10
10
|
module Render
|
11
11
|
module React
|
12
|
-
def initialize(*args, **kwargs)
|
13
|
-
Compiler.load_components
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
12
|
def render_react(component_class, **props)
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
Compiler.load_components
|
14
|
+
"<span data-react-isomorphic='true' " \
|
15
|
+
"data-react-component='#{component_class}' " \
|
16
|
+
"data-react-props='#{JSON.dump(props)}'>" \
|
17
|
+
"#{Compiler.render(component_class, **props)}" \
|
18
|
+
'</span>'
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -23,6 +23,7 @@ module Render
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def load_components
|
26
|
+
return if @components_loaded
|
26
27
|
Config.paths.each do |path|
|
27
28
|
files = Dir.glob(File.join(path, '**', '*.js'))
|
28
29
|
files.each do |filename|
|
@@ -31,6 +32,7 @@ module Render
|
|
31
32
|
lookup[name.to_sym] = true
|
32
33
|
end
|
33
34
|
end
|
35
|
+
@components_loaded = true
|
34
36
|
end
|
35
37
|
|
36
38
|
def render(component_class, **props)
|
@@ -20,7 +20,9 @@ module Render
|
|
20
20
|
|
21
21
|
def babelify(filepath)
|
22
22
|
code = File.read(filepath)
|
23
|
-
|
23
|
+
component_name_match = code.match(/export default (\w+?);/)
|
24
|
+
raise "can't find component name in #{filepath}" unless component_name_match
|
25
|
+
component_name = component_name_match[1]
|
24
26
|
|
25
27
|
code.gsub!(/export[^;]+;/, '')
|
26
28
|
code.gsub!(/import[^;]+;/, '')
|
data/lib/render/react/version.rb
CHANGED