Class: TurboLive::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo_live/renderer.rb

Class Method Summary collapse

Class Method Details

.render(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/turbo_live/renderer.rb', line 6

def render(data)
  # build the payload
  payload = extract_payload(data)
  # create the component
  component = build_component(data)
  # run the update function
  result = component.update payload
  return if result == TurboLive::SKIP_RENDER

  # render the replace stream
  "    <turbo-stream action=\"replace\" method=\"morph\" target=\"\#{data[:id]}\">\n      <template>\n        \#{component.call}\n      </template>\n    </turbo-stream>\n  STREAM\nrescue SkipRender\n  nil\nend\n"