render-later 1.0.0 → 1.1.0

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: e1124bb4e36a64975fbdc6b79b35bbccf1afaf03
4
- data.tar.gz: b8d83484ce27bb6a415238ecc88069e126bad8d6
3
+ metadata.gz: 55370f11139243c05ff90f7daf2c71d46fe1f20c
4
+ data.tar.gz: 70b2a0834e7502ea42de2525157eea36fc07fdb1
5
5
  SHA512:
6
- metadata.gz: 860835d8c1a20743fd278850de9a5f66cb3d9131d8829a41a3eb6dd43611d98f4c4586ef17b8d792da564344db65b2fc7eb842622c7a8b4b5512a540ae9d513d
7
- data.tar.gz: 63718790b5cac1da165f5e22be2960ea41370302d65cfd46f7b416aeb42b3a73a557c1299fa26a74350faba3cc4ef11244b959d6e65c7e66480e7d08038dc0ec
6
+ metadata.gz: bfdd1c0a4dbda416582e61c88dbdf5da2d503c1908adff8f2ba2964020908514fe4d526d64105e069ad959ddd0d888eb345d1d0856e421646041d56b4bc3c508
7
+ data.tar.gz: 9f02642e7c9cc19d81c3d233d22cb08b153e067ae8160fea10005f86b56de54ee276dd15181da16aec924544f877981a69987794b4f951dbcfc144ff1be4b4b2
@@ -1,13 +1,13 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1.8
5
- - 2.2.4
6
- - 2.3.0
4
+ - 2.3.4
5
+ - 2.4.1
7
6
  gemfile:
8
- - test/gemfiles/rails-4.1.gemfile
9
7
  - test/gemfiles/rails-4.2.gemfile
8
+ - test/gemfiles/rails-5.0.gemfile
9
+ - test/gemfiles/rails-5.1.gemfile
10
10
  matrix:
11
11
  include:
12
- - rvm: 2.3.0
13
- gemfile: test/gemfiles/rails-5.0.gemfile
12
+ - rvm: 2.3.4
13
+ gemfile: test/gemfiles/rails-4.1.gemfile
@@ -0,0 +1,11 @@
1
+ # v1.1.0
2
+
3
+ Add support for render-later in tables and other elements:
4
+ * Add ability to customize placeholder tag (#2)
5
+ * Fix javascript temporary element to match parent one (#2)
6
+
7
+ # v1.0.0
8
+
9
+ Initial production release
10
+
11
+ _Sept 10, 2016_
data/README.md CHANGED
@@ -25,7 +25,14 @@ In your views, simply wrap a slow piece of code into a `render_later` block, and
25
25
  <% end %>
26
26
  </div>
27
27
  ```
28
- It's important to use the `<%=` erb tag here, as the helper will render a hidden span tag.
28
+ It's important to use the `<%=` erb tag here, as the helper will render a hidden `span` tag. If a `span` tag doesn't work well for you (ex: in a table), you can customize the placeholder element with the `tag` keyword argument, ex:
29
+ ```erb
30
+ <table>
31
+ <%= render_later "srv-uptime-#{server.id}", tag: :tr do %>
32
+ <tr><td><%= server.uptime %></td></tr>
33
+ <% end %>
34
+ </table>
35
+ ```
29
36
 
30
37
  In your layout, before the end of the body tag, add a call to `render_now`:
31
38
  ```erb
@@ -36,6 +43,14 @@ In your layout, before the end of the body tag, add a call to `render_now`:
36
43
  ```
37
44
  This is where the deferred blocks will be rendered and injected into the page using inline javascript.
38
45
 
46
+ And finally in your controller, you need to render with the `stream` option:
47
+
48
+ ```ruby
49
+ def index
50
+ render stream: true
51
+ end
52
+ ```
53
+
39
54
  ## Performance
40
55
 
41
56
  Performance-wise, this approach is quite interesting, let me explain why:
@@ -140,7 +155,6 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
140
155
  - Wider test coverage across browsers using [Sauce Labs](https://saucelabs.com/opensauce/)
141
156
  - Parallel rendering (I tried quickly but the `capture` helper isn't thread-safe)
142
157
  - Add options to do caching at the same time (with the same key)
143
- - Add options to customize the generated temporary element (could be used for loading indication or to avoid CSS conflict)
144
158
 
145
159
  ## License
146
160
 
@@ -3,7 +3,7 @@ module RenderLater
3
3
  INSERT_FUNCTION = <<-JAVASCRIPT.freeze
4
4
  function rl_insert(name, data) {
5
5
  if (node = document.getElementById(name)) {
6
- var div = document.createElement('div');
6
+ var div = document.createElement(node.parentNode.tagName || 'div');
7
7
  div.innerHTML = data;
8
8
  var elements = div.childNodes;
9
9
  for (var i = elements.length; i > 0; i--) {
@@ -14,9 +14,9 @@ module RenderLater
14
14
  };
15
15
  JAVASCRIPT
16
16
 
17
- def render_later key, &block
17
+ def render_later key, tag: :span, class: "rl-placeholder", &block
18
18
  store_object(key, &block)
19
- content_tag(:span, nil, id: "rl-#{key}", class: "rl-placeholder", style: 'display: none')
19
+ content_tag(tag, nil, id: "rl-#{key}", class: binding.local_variable_get(:class), style: 'display: none')
20
20
  end
21
21
 
22
22
  def render_now
@@ -1,3 +1,3 @@
1
1
  module RenderLater
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "minitest", "~> 5.0"
25
- spec.add_development_dependency "rails", "~> 4.0"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "rails", "~> 5.1"
26
26
  spec.add_development_dependency "puma"
27
27
  spec.add_development_dependency "poltergeist"
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render-later
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Jarthon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '4.0'
61
+ version: '5.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '4.0'
68
+ version: '5.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: puma
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +105,7 @@ extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
107
  - ".travis.yml"
108
+ - CHANGELOG.md
108
109
  - Gemfile
109
110
  - LICENSE.txt
110
111
  - README.md
@@ -139,4 +140,3 @@ signing_key:
139
140
  specification_version: 4
140
141
  summary: Defer rendering of slow parts to the end of the page
141
142
  test_files: []
142
- has_rdoc: