Class: Bootstrap5Helper::Tab::Content
- Defined in:
- lib/bootstrap5_helper/tab/content.rb
Overview
Build a Content component to be used with Tabs
Instance Method Summary collapse
-
#initialize(template, opts = {}, &block) ⇒ Content
constructor
Class constructor.
-
#pane(source, opts = {}, &block) ⇒ String
Builds the pane for the tab.
-
#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, opts = {}, &block) ⇒ Content
Class constructor
15 16 17 18 19 20 21 22 |
# File 'lib/bootstrap5_helper/tab/content.rb', line 15 def initialize(template, opts = {}, &block) super(template) @id = opts.fetch(:id, uuid) @class = opts.fetch(:class, '') @data = opts.fetch(:data, {}) @content = block || proc { '' } end |
Instance Method Details
#pane(source, opts = {}, &block) ⇒ String
Builds the pane for the tab.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bootstrap5_helper/tab/content.rb', line 32 def pane(source, opts = {}, &block) id = opts.fetch(:id, source) klass = opts.fetch(:class, '') data = opts.fetch(:data, {}) content_tag( :div, id: id, class: "tab-pane #{klass}", role: 'tabpanel', data: data, &block ) end |
#to_s ⇒ String
String representation of the object.
51 52 53 54 55 |
# File 'lib/bootstrap5_helper/tab/content.rb', line 51 def to_s content_tag :div, id: @id, class: "tab-content #{@class}" do @content.call(self) end end |