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 23 |
# File 'lib/bootstrap5_helper/callout.rb', line 14 def initialize(template, = nil, opts = {}, &block) super(template) @context, args = (, opts) @attrs = args @id = @attrs.delete(:id) { nil } @class = @attrs.delete(:class) { '' } @data = @attrs.delete(:data) { {} } @content = block || proc { '' } end |
Instance Method Details
#header(text_or_options = nil, opts = {}, &block) ⇒ String
Creates the header component for the Callout.
34 35 36 37 |
# File 'lib/bootstrap5_helper/callout.rb', line 34 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.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bootstrap5_helper/callout.rb', line 43 def to_s content_tag( :div, { id: @id, class: container_class, data: @data }.merge(@attrs) ) do @content.call(self) end end |