Sha256: 55a23dd08bb83cc63b4440df6db8c1e76a646697a2920363c45f9a95e2ade0bb

Contents?: true

Size: 972 Bytes

Versions: 7

Compression:

Stored size: 972 Bytes

Contents

module Coco
  module UrlHelper
    include ActionView::Helpers::UrlHelper

    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

    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::ButtonTo.new(action: options, type: :submit, **html_options)
      button = button.with_content(name) unless block
      render(button, &block)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
coveragebook_components-0.12.2 app/helpers/coco/url_helper.rb
coveragebook_components-0.12.1 app/helpers/coco/url_helper.rb
coveragebook_components-0.12.0 app/helpers/coco/url_helper.rb
coveragebook_components-0.11.0 app/helpers/coco/url_helper.rb
coveragebook_components-0.10.1.beta.2 app/helpers/coco/url_helper.rb
coveragebook_components-0.10.1.beta.1 app/helpers/coco/url_helper.rb
coveragebook_components-0.10.1.beta.0 app/helpers/coco/url_helper.rb