Class: Bootstrap3Helper::Panel
- Defined in:
- lib/bootstrap3_helper/panel.rb
Overview
Used to rapidly build Bootstrap Panel Components.
Instance Method Summary collapse
-
#body(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the body component for the panel.
-
#footer(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the footer component for the panel.
-
#header(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the header component for the panel.
-
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Panel
constructor
Creates a new Panel object.
-
#title(tag_or_options = nil, opts = {}, &block) ⇒ String
Builds a title component for the panel.
-
#to_s ⇒ String
Used to render the html for the entire panel object.
Methods inherited from Component
#concat, #config, #content_tag, #parse_arguments, #parse_context_or_options, #parse_tag_or_options, #uuid
Constructor Details
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Panel
Creates a new Panel object.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bootstrap3_helper/panel.rb', line 17 def initialize(template, = nil, opts = {}, &block) super(template) @context, args = (, opts) @id = args.fetch(:id, '') @class = args.fetch(:class, '') @data = args.fetch(:data, nil) @config_type = args.fetch(:config_type, :panels) @content = block || proc { '' } end |
Instance Method Details
#body(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the body component for the panel.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/bootstrap3_helper/panel.rb', line 94 def body( = nil, opts = {}, &block) tag, args = (, opts) id = args.fetch(:id, nil) klass = args.fetch(:class, '') data = args.fetch(:data, {}) aria = args.fetch(:aria, {}) content_tag( tag || config({ @config_type => :body }, :div), id: id, class: "panel-body #{klass}", data: data, aria: aria, &block ) end |
#footer(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the footer component for the panel.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/bootstrap3_helper/panel.rb', line 122 def ( = nil, opts = {}, &block) tag, args = (, opts) id = args.fetch(:id, nil) klass = args.fetch(:class, '') data = args.fetch(:data, {}) aria = args.fetch(:aria, {}) content_tag( tag || config({ @config_type => :footer }, :div), id: id, class: "panel-footer #{klass}", data: data, aria: aria, &block ) end |
#header(tag_or_options = nil, opts = {}, &block) ⇒ String
Used to generate the header component for the panel.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bootstrap3_helper/panel.rb', line 38 def header( = nil, opts = {}, &block) tag, args = (, opts) id = args.fetch(:id, nil) klass = args.fetch(:class, '') data = args.fetch(:data, {}) aria = args.fetch(:aria, {}) content_tag( tag || config({ @config_type => :header }, :div), id: id, class: "panel-heading #{klass}", data: data, aria: aria, &block ) end |
#title(tag_or_options = nil, opts = {}, &block) ⇒ String
Builds a title component for the panel.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bootstrap3_helper/panel.rb', line 66 def title( = nil, opts = {}, &block) tag, args = (, opts) id = args.fetch(:id, nil) klass = args.fetch(:class, '') data = args.fetch(:data, {}) aria = args.fetch(:aria, {}) content_tag( tag || config({ @config_type => :title }, :h3), id: id, class: "panel-title #{klass}", data: data, aria: aria, &block ) end |
#to_s ⇒ String
Used to render the html for the entire panel object.
144 145 146 147 148 |
# File 'lib/bootstrap3_helper/panel.rb', line 144 def to_s content_tag :div, id: @id, class: container_classes, data: @data do @content.call(self) end end |