Class: Bootstrap5Helper::Callout
- Defined in:
- lib/bootstrap5_helper/callout.rb
Overview
Builds a Toast component.
Instance Method Summary collapse
-
#header(text_or_options = nil, opts = {}, &block) ⇒ String
Creates the header component for the Callout.
- #initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Callout constructor
-
#to_s ⇒ String
Returns a string representation of the 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) ⇒ Callout
14 15 16 17 18 19 20 21 22 |
# File 'lib/bootstrap5_helper/callout.rb', line 14 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
#header(text_or_options = nil, opts = {}, &block) ⇒ String
Creates the header component for the Callout.
33 34 35 36 |
# File 'lib/bootstrap5_helper/callout.rb', line 33 def header( = nil, opts = {}, &block) text = .is_a?(String) ? : nil content_tag(config({ callouts: :header }, :h4), text, opts, &block) end |
#to_s ⇒ String
Returns a string representation of the component.
42 43 44 45 46 |
# File 'lib/bootstrap5_helper/callout.rb', line 42 def to_s content_tag :div, id: @id, class: container_class, data: @data do @content.call(self) end end |