Class: Bootstrap5Helper::InputGroup
- Defined in:
- lib/bootstrap5_helper/input_group.rb
Overview
The InputGroup helper is meant to help you rapidly build Bootstrap input group components quickly and easily.
Instance Method Summary collapse
-
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ InputGroup
constructor
Class constructor.
-
#text(opts = {}, &block) ⇒ String
This is the element that actually houses the icon or text used in the input group.
-
#to_s ⇒ String
Used to render out the InputGroup component.
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) ⇒ InputGroup
Class constructor
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bootstrap5_helper/input_group.rb', line 16 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
#text(opts = {}, &block) ⇒ String
This is the element that actually houses the icon or text used in the input group.
33 34 35 36 |
# File 'lib/bootstrap5_helper/input_group.rb', line 33 def text(opts = {}, &block) opts[:class] = (opts[:class] || '') << ' input-group-text' content_tag :span, opts, &block end |
#to_s ⇒ String
Used to render out the InputGroup component.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bootstrap5_helper/input_group.rb', line 42 def to_s content_tag( :div, id: @id, class: "input-group #{size_class} #{@class}", data: @data ) do @content.call(self) end end |