Sha256: 58e1a14ae1f67b9b2da412651b6b3a1cfafecf1435eefd60c829065c40836fb1

Contents?: true

Size: 804 Bytes

Versions: 2

Compression:

Stored size: 804 Bytes

Contents

module Bootstrap
  module ViewHelpers
    module Components
      class Button < Component
        class Link < Button
          def to_html
            verify_disabled_link
            link_to(label, href, html_options)
          end

          protected

          attr_reader :href

          def verify_disabled_link
            return unless options[:disabled]
            options[:tabindex] = '-1'
          end

          def inject_class_name_to_options
            super
            options[:class] << ' disabled' if options[:disabled]
          end

          def html_options
            options.merge({ role: :button })
          end

          def inject_additional_attributes
            super
            @href = options.delete(:href)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootstrap-view_helpers-0.0.3 lib/bootstrap/view_helpers/components/button/link.rb
bootstrap-view_helpers-0.0.2 lib/bootstrap/view_helpers/components/button/link.rb