Class: Cybertrain::TurboStreams

Inherits:
Object
  • Object
show all
Defined in:
cybertrain/turbo_stream_renderer.rb

Instance Method Summary collapse

Instance Method Details

#after(target, partial: "", locals: {}, html: nil) ⇒ SafeString

Inserted after the target (see #replace).

Returns:



76
77
78
# File 'cybertrain/turbo_stream_renderer.rb', line 76

def after(target, partial: "", locals: {}, html: nil)
  stream("after", target, partial, locals, html)
end

#append(target, partial: "", locals: {}, html: nil) ⇒ SafeString

Added at the end of the target’s content (see #replace).

Returns:



55
56
57
# File 'cybertrain/turbo_stream_renderer.rb', line 55

def append(target, partial: "", locals: {}, html: nil)
  stream("append", target, partial, locals, html)
end

#before(target, partial: "", locals: {}, html: nil) ⇒ SafeString

Inserted before the target (see #replace).

Returns:



69
70
71
# File 'cybertrain/turbo_stream_renderer.rb', line 69

def before(target, partial: "", locals: {}, html: nil)
  stream("before", target, partial, locals, html)
end

#prepend(target, partial: "", locals: {}, html: nil) ⇒ SafeString

Added at the start of the target’s content (see #replace).

Returns:



62
63
64
# File 'cybertrain/turbo_stream_renderer.rb', line 62

def prepend(target, partial: "", locals: {}, html: nil)
  stream("prepend", target, partial, locals, html)
end

#remove(target) ⇒ SafeString

<turbo-stream action="remove" target="...">.

Parameters:

Returns:



84
85
86
# File 'cybertrain/turbo_stream_renderer.rb', line 84

def remove(target)
  Turbo.remove(target)
end

#replace(target, partial: "", locals: {}, html: nil) ⇒ SafeString

<turbo-stream action="replace" target="...">: the target (a DOM id String, or a record, whose dom_id it is) replaced by exactly one of the partial (with its locals) and html: (escaped unless a SafeString).

Parameters:

  • target (String, Model)
  • partial (String) (defaults to: "") —

    a partial’s name, "" for none

  • locals (Hash{Symbol => Object}) (defaults to: {}) —

    the partial’s locals

  • html (String, SafeString, nil) (defaults to: nil)

Returns:



41
42
43
# File 'cybertrain/turbo_stream_renderer.rb', line 41

def replace(target, partial: "", locals: {}, html: nil)
  stream("replace", target, partial, locals, html)
end

#update(target, partial: "", locals: {}, html: nil) ⇒ SafeString

The target’s content replaced (see #replace for the arguments).

Returns:



48
49
50
# File 'cybertrain/turbo_stream_renderer.rb', line 48

def update(target, partial: "", locals: {}, html: nil)
  stream("update", target, partial, locals, html)
end