render_turbo_stream 4.0.1 → 4.0.3

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: caa22ab0fcd032899bc52bb3e92bc576e26bea6bb187acbe0e00b3162e78c054
4
- data.tar.gz: 7314b1bb2199fb89fc83df166c5a02749c82b291ab0210ababbf1afffedfb72a
3
+ metadata.gz: b7a06cc371f6543af918f87ee1d80f4c3e4c9640f10bc69b540d98ee1e5e7e20
4
+ data.tar.gz: 69112643c6597fc51fd669d48b467bebcf100bb690f3028775cd661b72ce1568
5
5
  SHA512:
6
- metadata.gz: a99d072daf0c5cfb3955790ba17aa63ddbabdd7332ced553f06abb988ad5150329f1a787da4d03b58d34b088398d6ec64b3774fde34b429f46837e13ac11418a
7
- data.tar.gz: 6d16c9a72c015961e6597847d664806871f550088b0a54f8a4e4f0c0df186844de4ca1838159fcfe8243f76de0c8ca53fa0513aa688c7e091db5d648491b4d8b
6
+ metadata.gz: a8790ae754ac41af06d4d375fd205eae8316c0b05551eace0c3aabe56572f7e91cd505aa40d9671d6856339468342319564bd1feea1815011cc3c097af499838
7
+ data.tar.gz: 671730ab4d5df1918b05bd4a768336878f9d93a3cc0c43610359dd3847f85e7fd141cb6fbf99cfe6edae934afa247fa9fbb3db3d18106a02639b2a8b64478573
data/README.md CHANGED
@@ -8,7 +8,7 @@ Defining templates like `(create|update).turbo_stream.haml` is a heavy mix of lo
8
8
 
9
9
  For `:replace` actions, responses must be wrapped inside a `turbo_frame_tag` with a matching `target_id`. The gem will regex the content and wrap it by a `turbo_frame_tag` if necessary but not present. This way the matching `target_id` is only defined in one place. This check only happens on the first call after restarting the application in production and on every call if precompile assets is set to true in configs.
10
10
 
11
- There are many different ways to handle **redirects** since turbo. The gem brings this into a workflow.
11
+ There are many different ways to handle **redirects** since turbo. Some details are handled here.
12
12
 
13
13
  Execute [turbo_power](https://github.com/marcoroth/turbo_power) commands such as adding a css class to an html element, can be sent directly from the controller.
14
14
 
@@ -13,13 +13,16 @@
13
13
 
14
14
  <% else %>
15
15
  <% ctl = { partial: args[:partial], target_id: args[:target_id], action: args[:action] } %>
16
+
17
+ <% target_id = RenderTurboStream::Libs.target_to_target_id(args[:target]) %>
18
+
16
19
  <% info = { target_id: args[:target_id], partial: args[:partial], locals: args[:locals] } %>
17
20
 
18
21
 
19
22
 
20
23
  <% if args[:action].present? %>
21
24
  <% Rails.logger.debug(" • render-turbo-stream #{args[:action].upcase} => #{info}") %>
22
- <%= turbo_stream.send args[:action].to_sym, RenderTurboStream::Libs.target_to_target_id(args[:target]) do %>
25
+ <%= turbo_stream.send args[:action].to_sym, target_id do %>
23
26
  <% if RenderTurboStream::CheckTemplate.new(partial: args[:partial], action: args[:action]).add_turbo_frame_tag? %>
24
27
  <%= turbo_frame_tag RenderTurboStream::Libs.target_to_target_id(args[:target]) do %>
25
28
  <%= render args[:partial], locals: args[:locals]&.symbolize_keys %>
@@ -1,8 +1,6 @@
1
1
  module RenderTurboStream
2
2
  class CheckTemplate
3
3
 
4
- AUTO_ADD_TURBO_FRAME_TAG_ON_ACTION = [:replace]
5
-
6
4
  def initialize(partial: nil, template: nil, available_instance_variables: nil, action: nil)
7
5
  if !partial && !template
8
6
  raise 'missing attribute partial xor template'
@@ -69,7 +67,8 @@ module RenderTurboStream
69
67
  end
70
68
  end
71
69
 
72
- if stack_level == 1 && AUTO_ADD_TURBO_FRAME_TAG_ON_ACTION.include?(@action.to_sym)
70
+ conf = Rails.configuration.x.render_turbo_stream.auto_wrap_for_actions
71
+ if stack_level == 1 && conf.present? && conf.include?(@action.to_sym)
73
72
  unless _code.match(/(turbo_frame_tag|turbo-frame)/)
74
73
  @result[:add_turbo_frame_tag] = true
75
74
  end
@@ -55,7 +55,7 @@ module RenderTurboStream
55
55
  if_error_alerts,
56
56
  add_notices,
57
57
  add_alerts,
58
- )
58
+ )
59
59
  streams += flashes[:turbo_actions]
60
60
 
61
61
  streams += libs.additional_actions(
@@ -124,7 +124,11 @@ module RenderTurboStream
124
124
  elsif pr.is_a?(Hash)
125
125
  props = pr.symbolize_keys
126
126
  r = props
127
- r[:target] = RenderTurboStream::Libs.target_id_to_target(props[:target_id]) if props[:target_id].present?
127
+ if props[:target_id].present?
128
+ r[:target] = RenderTurboStream::Libs.target_id_to_target(props[:target_id])
129
+ else
130
+ r[:target] = props[:target]
131
+ end
128
132
  raise "Missing attribute :target in #{props}" if !props[:target].present?
129
133
  r.delete(:target_id)
130
134
  r[:action] = (props[:action].present? ? props[:action] : :replace)
@@ -150,7 +154,7 @@ module RenderTurboStream
150
154
 
151
155
  # renders a partial to turbo_stream
152
156
 
153
- def stream_partial( target_id, partial: nil, action: :replace, locals: {} )
157
+ def stream_partial(target_id, partial: nil, action: :replace, locals: {})
154
158
  render_turbo_stream(
155
159
  [
156
160
  {
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.3"
3
3
  end
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: 4.0.1
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian
@@ -24,12 +24,12 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.3
27
- description: Handles translated flash messages, sets status, wrapps partials in the
28
- necessary frames and renders via Turbo Stream or Turbo::StreamsChannel directly
29
- from the controller. No need to write *.turbo_stream.* templates. Together with
30
- the turbo_power gem or custom turbo_stream actions, it can run javascript. Redirects
31
- can be handled easily and in multiple ways. Through request testing helpers, this
32
- allows for consistent testing strategy.
27
+ description: 'It brings TurboStreams and TurboStreams::Channel together in a unified
28
+ workflow with one testing strategy. It separates logic and views: All partial handling
29
+ can be controlled directly from the controller. No need to write *.turbo_stream.*
30
+ templates. A normal partial can be sent in any way. Execution of javascript actions
31
+ can be done directly from the controller. Demo project with all this built in along
32
+ with system and request tests is available.'
33
33
  email:
34
34
  - christian@sedlmair.ch
35
35
  executables: []