Class: Bootstrap5Helper::Badge
- Defined in:
- lib/bootstrap5_helper/badge.rb
Overview
Creates Bootstrap badge components that can be used anywhere.
Instance Method Summary collapse
-
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Badge
constructor
Class constructor.
-
#to_s ⇒ String
String representation of the object.
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #parse_text_or_options, #uuid
Constructor Details
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Badge
Class constructor
15 16 17 18 19 20 21 22 23 |
# File 'lib/bootstrap5_helper/badge.rb', line 15 def initialize(template, = nil, opts = {}, &block) super(template) @context, args = (, opts) @id = args.fetch(:id, nil) @class = args.fetch(:class, '') @data = args.fetch(:data, {}) @content = block || proc { '' } end |
Instance Method Details
#to_s ⇒ String
String representation of the object.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bootstrap5_helper/badge.rb', line 29 def to_s content_tag( config({ badges: :base }, :span), id: @id, class: container_class, data: @data ) do @content.call(self) end end |