Module: TurboScroll::ViewHelpers

Defined in:
lib/turbo-scroll.rb

Instance Method Summary collapse

Instance Method Details

#turbo_scroll_auto(page:, loader_dom_id: :turbo_loader, loading_indicator: true, id: :infinite, &block) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/turbo-scroll.rb', line 8

def turbo_scroll_auto(page:, loader_dom_id: :turbo_loader, loading_indicator: true, id: :infinite, &block)
  if block_given?
    safe_concat(%{<div id="#{id}">})
    concat(capture(&block))
    safe_concat("</div>")
  end
  render(TurboScroll::Auto.new(page: page, loader_dom_id: loader_dom_id, loading_indicator: loading_indicator))
end

#turbo_scroll_auto_stream(page:, loader_dom_id: :turbo_loader, infinite_dom_id: :infinite, loading_indicator: true, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/turbo-scroll.rb', line 28

def turbo_scroll_auto_stream(page:, loader_dom_id: :turbo_loader, infinite_dom_id: :infinite, loading_indicator: true, &block)
  render(
    TurboScroll::AutoStream.new(
      page: page,
      loader_dom_id: loader_dom_id,
      infinite_dom_id: infinite_dom_id,
      loading_indicator: loading_indicator
    ),
    &block
  )
end

#turbo_scroll_more(page:, loader_dom_id: :turbo_loader, id: :infinite, &block) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/turbo-scroll.rb', line 18

def turbo_scroll_more(page:, loader_dom_id: :turbo_loader, id: :infinite, &block)
  if block_given?
    safe_concat(%{<div id="#{id}">})
    concat(capture(&block))
    safe_concat("</div>")
  end
  render(TurboScroll::More.new(page: page, loader_dom_id: loader_dom_id))
end

#turbo_scroll_more_stream(page:, loader_dom_id: :turbo_loader, infinite_dom_id: :infinite, &block) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/turbo-scroll.rb', line 41

def turbo_scroll_more_stream(page:, loader_dom_id: :turbo_loader, infinite_dom_id: :infinite, &block)
  render(
    TurboScroll::MoreStream.new(
      page: page,
      loader_dom_id: loader_dom_id,
      infinite_dom_id: infinite_dom_id
    ),
    &block
  )
end