render_turbo_stream 2.0.1 → 2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9858266fb82670a9ef99550a3acb17c4d744299969634a16dc34f05a62b6e5e7
|
4
|
+
data.tar.gz: 445dd3768ef6674b7286fb55d7738f9c112c31f5d57841f8fb8b4390c64b31af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dae6e979f4abed3f7b287a9fe5d39d8a2b3c7d0e92f4048d1bc551ddedfd39fd365c26cc8bf7be1c67d6e21a63f22670107e292ba50728db824c09ed48cbaf91
|
7
|
+
data.tar.gz: 1c5feab440874cc4f8e75324b60c1f352eb4a0cc54a38ff55598250f898e02bd5fbe454ea68fb6542a12f3b6c1eeab8493a2f7c146861c3010295eaedb58a7c2
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# RenderTurboStream
|
2
2
|
|
3
|
-
Defining templates like `(create|update).turbo_stream.haml` annoyed me.
|
4
|
-
|
5
|
-
The biggest advantage of this gem is the testing strategy.
|
3
|
+
Defining templates like `(create|update).turbo_stream.haml` annoyed me and I was looking for a testing strategy.
|
6
4
|
|
7
5
|
Working consistently with turbo_stream means shooting lots of partials from the backend to the frontend. This always requires the same attributes: the path to the partial, the html-id that turbo_stream points to, and maybe some locals. This gem serialises that: Partials can be controlled directly from the controller. It sets the status, generates a flash message, handles redirection, pushes it all to the front. Includes helpers for enabling request tests.
|
8
6
|
|
@@ -11,7 +11,6 @@ module RenderTurboStream
|
|
11
11
|
def cable_partial_to_channel(action, channel, partial, id, locals: nil)
|
12
12
|
|
13
13
|
# add headers for test
|
14
|
-
|
15
14
|
if Rails.env.test?
|
16
15
|
args = {
|
17
16
|
target: "##{id}",
|
@@ -20,12 +19,14 @@ module RenderTurboStream
|
|
20
19
|
partial: partial,
|
21
20
|
locals: locals
|
22
21
|
}
|
22
|
+
html = RenderTurboStreamRenderController.render(partial: partial, locals: locals)
|
23
23
|
h = response.headers.to_h
|
24
24
|
i = 1
|
25
25
|
loop do
|
26
26
|
k = "test-turbo-cable-#{i}"
|
27
27
|
unless h.keys.include?(k)
|
28
28
|
response.headers[k] = args.to_json
|
29
|
+
response.headers["#{k}-html"] = html.to_s
|
29
30
|
break
|
30
31
|
end
|
31
32
|
i += 1
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -245,7 +245,8 @@ module RenderTurboStream
|
|
245
245
|
cables = response.headers.to_h.select { |k| k.match(/^test-turbo-cable-[\d]+$/) }
|
246
246
|
cables.each do |k, v|
|
247
247
|
args = JSON.parse(v)
|
248
|
-
html = ApplicationController.render(partial: args['partial'], locals: args['locals'].symbolize_keys)
|
248
|
+
#html = ApplicationController.render(partial: args['partial'], locals: args['locals'].symbolize_keys)
|
249
|
+
html = response.headers["#{k}-html"]
|
249
250
|
res.push(
|
250
251
|
args.merge(
|
251
252
|
{
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_turbo_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
@@ -24,11 +24,11 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.0.4.3
|
27
|
-
description:
|
28
|
-
|
29
|
-
templates. Together with the turbo_power gem or custom
|
30
|
-
can run javascript. Redirects can now be handled easily
|
31
|
-
helpers for enabling request tests.
|
27
|
+
description: Handles translated flash messages, sets status, and renders partials
|
28
|
+
via Turbo Stream or Turbo::StreamsChannel directly from the controller. No need
|
29
|
+
to write *.turbo_stream.* templates. Together with the turbo_power gem or custom
|
30
|
+
turbo-stream actions, you can run javascript. Redirects can now be handled easily
|
31
|
+
and in multiple ways. Includes helpers for enabling request tests.
|
32
32
|
email:
|
33
33
|
- christian@sedlmair.ch
|
34
34
|
executables: []
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
40
|
- app/controllers/render_turbo_stream/application_controller.rb
|
41
|
+
- app/controllers/render_turbo_stream/render_turbo_stream_render_controller.rb
|
41
42
|
- app/models/render_turbo_stream/cable_stream.rb
|
42
43
|
- app/views/render_turbo_stream.html.erb
|
43
44
|
- app/views/render_turbo_stream.turbo_stream.erb
|