turbolinks_render 0.9.11 → 0.9.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60f02af004bd119d0d38ee2678d8128b93f1e6756c641c60972f7707e755593d
4
- data.tar.gz: cee50736d7790b5f9e795c4ad2421274cc3020c1b47e5ed56e48781ccb81784e
3
+ metadata.gz: 82792bd10eab5f8fbd096ae4ad70300046a2e8f6ebe86a7fddbf46485999ddc6
4
+ data.tar.gz: 5689e5ad06acacfd115401f31d22af1a38fcb0436ed499783fee1409fe967bb7
5
5
  SHA512:
6
- metadata.gz: 3dd95e4590be8d63d6c0b57ba1ee0199d5d222537a3fb623379774ff433b6bbfd2aeb56a5ad7a1e9d063431a4c3cd2450bc9630ea014b6e9274eb1f50250d771
7
- data.tar.gz: f31224ef7f37349d795982627ad50bb9902eebef345c62afa3e0f8210f31b16e2ae8e313fef79a691e67a03dc0814a8a007a3b4ff700d98316ea160af7435d2e
6
+ metadata.gz: 3dce7eede742f719282d4103ed573b6fa97f05d7499c9a0dd8ea8173c0b0813762336a670f444430984ba84c1b73cbba0693c11f1b24d29a221b006ee113badf
7
+ data.tar.gz: d9cfc2681b82792270646001468f60fa77657f5891bb7ce1b12633effe65f711ee74872a0ba2d4ab2ee67f72b252ff57bc865feb5aa8b6ed09f58b0969aec6d1
data/README.md CHANGED
@@ -53,13 +53,18 @@ In this case, to use turbolinks you should write:
53
53
  render turbolinks: true
54
54
  ```
55
55
 
56
+ ## Implementation notes
57
+
58
+ - It configures a rack middleware that intercept requests and modify responses when the expected conditions are met.
59
+ - It uses some internal Turbolinks classes to perform the rendering. This makes the DOM-update logic very smart but it could introduce problems with future Turbolink versions , since this does not belong to its public API. I'll do my best to keep things up to date.
60
+
56
61
  ## Example
57
62
 
58
63
  An [example](https://github.com/jorgemanrubia/rails-form-validations-example) and an [explanatory blog post](https://www.jorgemanrubia.com/2019/02/16/form-validations-with-html5-and-modern-rails/) are also available.
59
64
 
60
65
  ## Credits
61
66
 
62
- - [Implementation based on this idea by @nerdcave](https://github.com/turbolinks/turbolinks/issues/85#issuecomment-298347900).
67
+ - Original implementation based on [this idea by @nerdcave](https://github.com/turbolinks/turbolinks/issues/85#issuecomment-298347900).
63
68
 
64
69
  ## License
65
70
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -12,7 +12,7 @@ module TurbolinksRender
12
12
 
13
13
  Response = Struct.new(:status, :headers, :response) do
14
14
  def candidate_for_turbolinks?
15
- html_response?
15
+ html_response? && !empty?
16
16
  end
17
17
 
18
18
  def turbolinks_body
@@ -21,14 +21,21 @@ module TurbolinksRender
21
21
 
22
22
  private
23
23
 
24
+ def empty?
25
+ body.blank?
26
+ end
27
+
24
28
  def html_response?
25
29
  headers['Content-Type'] =~ /text\/html/
26
30
  end
27
31
 
28
32
  def body
29
- body = ''
30
- response.each {|part| body << part}
31
- body
33
+ @body ||= begin
34
+ body = ''
35
+ # Response does not have to be an Enumerable. It just has to respond to #each according to Rack spec
36
+ response.each {|part| body << part}
37
+ body
38
+ end
32
39
  end
33
40
 
34
41
  def js_code_to_render_html(html)
@@ -1,3 +1,3 @@
1
1
  module TurbolinksRender
2
- VERSION = '0.9.11'
2
+ VERSION = '0.9.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbolinks_render
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge Manrubia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails