Module: TurboRouter::ViewHelpers

Defined in:
lib/turbo_router/view_helpers.rb

Instance Method Summary collapse

Instance Method Details



13
14
15
16
17
18
19
# File 'lib/turbo_router/view_helpers.rb', line 13

def turbo_router_link_to(name = nil, options = nil, html_options = nil, &block)
  new_html_options = block_given? ? options : html_options
  new_html_options ||= {}
  new_html_options[:data] ||= {}
  new_html_options[:data][:turbo_frame] = "_top"
  block_given? ? link_to(name, new_html_options, nil, &block) : link_to(name, options, new_html_options, &block)
end

#turbo_router_load_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/turbo_router/view_helpers.rb', line 5

def turbo_router_load_to(name = nil, options = nil, html_options = nil, &block)
  new_html_options = block_given? ? options : html_options
  new_html_options ||= {}
  new_html_options[:data] ||= {}
  new_html_options[:data][:turbo] = false
  block_given? ? link_to(name, new_html_options, nil, &block) : link_to(name, options, new_html_options, &block)
end

#turbo_router_render_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/turbo_router/view_helpers.rb', line 21

def turbo_router_render_to(name = nil, options = nil, html_options = nil, &block)
  new_html_options = block_given? ? options : html_options
  new_html_options ||= {}
  new_html_options[:data] ||= {}
  new_html_options[:data][:turbo_frame] ||= :turbo_router_content
  block_given? ? link_to(name, new_html_options, nil, &block) : link_to(name, options, new_html_options, &block)
end

#turbo_router_route_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/turbo_router/view_helpers.rb', line 29

def turbo_router_route_to(name = nil, options = nil, html_options = nil, &block)
  new_html_options = block_given? ? options : html_options
  new_html_options ||= {}
  new_html_options[:data] ||= {}
  new_html_options[:data][:turbo_frame] ||= :turbo_router_content
  new_html_options[:data][:turbo_action] = "advance"
  block_given? ? link_to(name, new_html_options, nil, &block) : link_to(name, options, new_html_options, &block)
end