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(content = nil, options = nil, html_options = nil, &block) ⇒ Object



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

def coco_button_to(content = nil, options = nil, html_options = nil, &block)
  html_options, options = options, content if block
  options ||= {}
  html_options ||= {}

  button = Coco::App::Elements::FormButton.new(action: options, **html_options)
  button = button.with_content(content) unless block

  render(button, &block)
end


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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)
  html_options[:classes] = html_options[:class]
  html_options.delete(:class)

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

  link = Coco::Link::Component.new(href: href, **html_options)
  link = link.with_content(name) unless block

  render(link, &block)
end