Class: Bootstrap3Helper::Tabs::Content
- Defined in:
- lib/bootstrap3_helper/tabs/content.rb
Overview
Used to rapidly generated Bootstrap Tabs Content Components.
Instance Method Summary collapse
-
#initialize(template, args = {}, &block) ⇒ Content
constructor
Creates a new Tabs::Menu object.
-
#pane(name, args = {}) ⇒ Object
Adds a new tabe pane item to the object.
-
#to_s ⇒ String
Used to render out the object as HTML.
Methods inherited from Component
#concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #uuid
Constructor Details
#initialize(template, args = {}, &block) ⇒ Content
Creates a new Tabs::Menu object.
15 16 17 18 19 20 21 22 |
# File 'lib/bootstrap3_helper/tabs/content.rb', line 15 def initialize(template, args = {}, &block) super(template) @id = args.fetch(:id, nil) @class = args.fetch(:class, '') @data = args.fetch(:data, {}) @content = block || proc { '' } end |
Instance Method Details
#pane(name, args = {}) ⇒ Object
Adds a new tabe pane item to the object.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bootstrap3_helper/tabs/content.rb', line 32 def pane(name, args = {}) data = args.fetch(:data, nil) klass = args.fetch(:class, '') active = klass.include? 'active' content_tag( :div, id: name, class: "tab-pane fade #{active ? 'in' : ''} #{klass}", aria: { hidden: active }, data: data, role: 'tabpanel', tabindex: -1 ) do yield if block_given? end end |
#to_s ⇒ String
Used to render out the object as HTML
54 55 56 57 58 |
# File 'lib/bootstrap3_helper/tabs/content.rb', line 54 def to_s content_tag :div, id: @id, class: 'tab-content' + @class do @content.call(self) end end |