render-react 0.0.1 → 0.0.2

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: 20e6899a0f87ebdc9a12153275499f8946da1f22
4
- data.tar.gz: 452d9e25097b495d8a756bfa4aa07e9a04d518d1
3
+ metadata.gz: 034cfe68457045e81b4c578ca14fa5ba692c7dc0
4
+ data.tar.gz: f9d63c8fa6b963ac7632a4c3f9a981647bba64f6
5
5
  SHA512:
6
- metadata.gz: 364a292c52f5008af339f22d80eddfd525300e0914456716174c4ae9c7671bfcc117600221dfa5d5ac7a48b2018a1f1de8361818b8f159a20a34436c46e091fa
7
- data.tar.gz: b88136138f683301664b5e1f174fd7babdaabb93e6c69e012ab21951e0b2ce67f8335ae7faf738d6e0e074258f2bd3e782e2f6aafd15cfa16c67f6a60ebed903
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
- <<-EOS
19
- <span data-react-isomorphic='true' data-react-component='#{component_class}' data-react-props='#{JSON.dump(props)}'>#{Compiler.render(component_class, **props)}</span>
20
- EOS
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
- component_name = code.match(/export default (\w+?);/)[1]
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[^;]+;/, '')
@@ -1,5 +1,5 @@
1
1
  module Render
2
2
  module React
3
- VERSION = '0.0.1'.freeze
3
+ VERSION = '0.0.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Krasnoschekov