render-react 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/render/react/compiler.rb +5 -2
- data/lib/render/react/config.rb +10 -2
- data/lib/render/react/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef894396e5e208e6ac5780d12e4b1da22411b4f
|
4
|
+
data.tar.gz: c3bfac33319a8c7f18db3e5323977e1bbdae075b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686d05b4d73a319ff2f3d46abc2e786317115a470109a068d7bf07f99729483f0e847a8b29f943f9bdbaa9525eefadfd8fd602a6c264f430e8a3754442736a5d
|
7
|
+
data.tar.gz: ed31c4f793fce79fd8ed50faf4518322d82c607a85b79b2d229dcee7ba3c77dae05d4bc4eec68f0aa5fa245b668cb7fe772fc15a42c46120aa4f4e922c36cb48
|
data/README.md
CHANGED
@@ -11,19 +11,21 @@ It uses [V8 engine](https://developers.google.com/v8/) as dynamic library for Ja
|
|
11
11
|
## Installation
|
12
12
|
Just add render-react to your Gemfile and you're done.
|
13
13
|
```bash
|
14
|
-
echo
|
14
|
+
echo "gem 'render-react'" >> Gemfile
|
15
15
|
bundle install
|
16
16
|
```
|
17
17
|
|
18
18
|
## Usage (Rails)
|
19
|
-
1. Include Render::React into your ApplicationHelper
|
19
|
+
#### 1. Include Render::React into your ApplicationHelper
|
20
|
+
|
20
21
|
```ruby
|
21
22
|
module ApplicationHelper
|
22
23
|
include Render::React
|
23
24
|
...
|
24
25
|
```
|
25
26
|
|
26
|
-
2. Create initializer config/initializers/render_react.rb
|
27
|
+
#### 2. Create initializer config/initializers/render_react.rb
|
28
|
+
|
27
29
|
```ruby
|
28
30
|
Render::React::Config.path File.join(Rails.root, 'app/assets/javascripts/components-local')
|
29
31
|
Render::React::Config.path File.join(Rails.root, 'some/other/directory')
|
@@ -36,7 +38,8 @@ Render::React::Config.path(
|
|
36
38
|
)
|
37
39
|
```
|
38
40
|
|
39
|
-
3. Render react component into your view (e.g. slim)
|
41
|
+
#### 3. Render react component into your view (e.g. slim)
|
42
|
+
|
40
43
|
```ruby
|
41
44
|
== render_react 'Card', \
|
42
45
|
className: 'city-block swiper-slide', \
|
@@ -7,7 +7,7 @@ module Render
|
|
7
7
|
|
8
8
|
def create_context
|
9
9
|
@cxt = Config.new_context
|
10
|
-
@durability = Config
|
10
|
+
@durability = Config.durability
|
11
11
|
|
12
12
|
js_lib_files = Dir.glob(
|
13
13
|
File.join(
|
@@ -35,10 +35,13 @@ module Render
|
|
35
35
|
def bootstrap
|
36
36
|
if @durability
|
37
37
|
if @durability <= 1
|
38
|
-
@cxt
|
38
|
+
old_cxt = @cxt
|
39
|
+
|
39
40
|
@cxt = nil
|
40
41
|
create_context
|
41
42
|
load_components
|
43
|
+
|
44
|
+
old_cxt.dispose
|
42
45
|
else
|
43
46
|
@durability -= 1
|
44
47
|
end
|
data/lib/render/react/config.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
module Render
|
2
2
|
module React
|
3
3
|
module Config
|
4
|
-
|
4
|
+
@context_durability = 100_000
|
5
|
+
|
6
|
+
def set_durability(number)
|
7
|
+
@context_durability = number
|
8
|
+
end
|
9
|
+
|
10
|
+
def durability
|
11
|
+
@context_durability
|
12
|
+
end
|
5
13
|
|
6
14
|
def path(*paths)
|
7
15
|
@paths ||= []
|
@@ -22,7 +30,7 @@ module Render
|
|
22
30
|
@gem_js_path ||= File.expand_path('../../../../js/dist', __FILE__)
|
23
31
|
end
|
24
32
|
|
25
|
-
module_function :path, :paths, :new_context, :gem_js_path
|
33
|
+
module_function :path, :paths, :new_context, :gem_js_path, :set_durability, :durability
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
data/lib/render/react/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render-react
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Krasnoschekov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: therubyracer
|