Sha256: 3bf0dc20acbb809918050570c5371cdfcf3f5460a6d82c11e4f11e16c3e16fe2

Contents?: true

Size: 1019 Bytes

Versions: 16

Compression:

Stored size: 1019 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)
      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

    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
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
coveragebook_components-0.7.1 app/helpers/coco/url_helper.rb
coveragebook_components-0.7.0 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.5 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.4 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.3 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.2 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.1 app/helpers/coco/url_helper.rb
coveragebook_components-0.6.0 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.7 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.6 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.5 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.4 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.3 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.2 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.1 app/helpers/coco/url_helper.rb
coveragebook_components-0.5.0 app/helpers/coco/url_helper.rb