turbolinks_render 0.9.11 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/turbolinks_render/middleware.rb +11 -4
- data/lib/turbolinks_render/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82792bd10eab5f8fbd096ae4ad70300046a2e8f6ebe86a7fddbf46485999ddc6
|
4
|
+
data.tar.gz: 5689e5ad06acacfd115401f31d22af1a38fcb0436ed499783fee1409fe967bb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
-
|
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
|
-
|
31
|
-
|
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)
|
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.
|
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-
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|