Sha256: 78fbdb19e94f51b5a4c14dc8d316491336122e9e1213105f97872ff186ce72e4

Contents?: true

Size: 757 Bytes

Versions: 2

Compression:

Stored size: 757 Bytes

Contents

require_relative '../contextual_classes'

module Bootstrap
  module ViewHelpers
    module Components
      class Badge < Component
        def to_html
          content_tag(:span, options) { options[:label] || block.call }
        end

        # Defaults to true
        def fade?
          return true if options[:fade].nil?
          options[:fade]
        end

        protected

        def parse_options(opts)
          super
          inject_class_name
        end

        def inject_class_name
          pill = options[:pill] ? 'badge-pill' : ''
          class_name = "badge badge-#{style} #{pill} "
          class_name << options[:class] if options[:class].present?
          options[:class] = class_name
        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/badge.rb
bootstrap-view_helpers-0.0.2 lib/bootstrap/view_helpers/components/badge.rb