Module: Coco::UrlHelper

Includes:
ActionView::Helpers::UrlHelper
Included in:
Helpers
Defined in:
app/helpers/coco/url_helper.rb

Instance Method Summary collapse

Instance Method Details

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



19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/coco/url_helper.rb', line 19

def coco_button_to(name = nil, options = nil, html_options = nil, &block)
  html_options, options = options, name if block
  options ||= {}
  html_options ||= {}
  html_options.symbolize_keys!

  button = Coco::App::Elements::ButtonTo.new(action: options, type: :submit, **html_options)
  button = button.with_content(name) unless block
  render(button, &block)
end


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/coco/url_helper.rb', line 5

def coco_link_to(name = nil, options = nil, html_options = nil, &block)
  html_options, options, name = options, name, block if block
  options ||= {}
  html_options = Coco::ActionViewHelper.convert_options_to_data_attributes(options, html_options)

  href = Coco::ActionViewHelper.url_target(name, options)

  if block
    coco_link(href, **html_options.symbolize_keys!, &block)
  else
    coco_link(name, href, **html_options.symbolize_keys!)
  end
end