Class: Bootstrap3Helper::Panel
- Defined in:
- lib/bootstrap3_helper/panel.rb
Overview
Used to rapidly build Bootstrap Panel Components.
Instance Method Summary collapse
-
#body(args = {}, &block) ⇒ Object
Used to generate the body component for the panel.
-
#footer(args = {}, &block) ⇒ Object
Used to generate the footer component for the panel.
-
#header(args = {}, &block) ⇒ Object
Used to generate the header component for the panel.
-
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Panel
constructor
Creates a new Panel object.
-
#to_s ⇒ String
Used to render the html for the entire panel object.
Methods inherited from Component
#concat, #content_tag, #parse_arguments, #uuid
Constructor Details
#initialize(template, context_or_options = nil, opts = {}, &block) ⇒ Panel
Creates a new Panel object.
26 27 28 29 30 31 32 33 34 |
# File 'lib/bootstrap3_helper/panel.rb', line 26 def initialize(template, = nil, opts = {}, &block) super(template) @context, args = parse_arguments(, opts) @id = args.fetch(:id, '') @class = args.fetch(:class, '') @data = args.fetch(:data, nil) @content = block || proc { '' } end |
Instance Method Details
#body(args = {}, &block) ⇒ Object
Used to generate the body component for the panel.
59 60 61 62 63 64 |
# File 'lib/bootstrap3_helper/panel.rb', line 59 def body(args = {}, &block) id = args.fetch(:id, '') klass = args.fetch(:class, '') content_tag(:div, id: id, class: 'panel-body ' + klass, &block) end |
#footer(args = {}, &block) ⇒ Object
Used to generate the footer component for the panel.
73 74 75 76 77 78 |
# File 'lib/bootstrap3_helper/panel.rb', line 73 def (args = {}, &block) id = args.fetch(:id, '') klass = args.fetch(:class, '') content_tag(:div, id: id, class: 'panel-footer ' + klass, &block) end |
#header(args = {}, &block) ⇒ Object
Used to generate the header component for the panel.
43 44 45 46 47 48 49 50 |
# File 'lib/bootstrap3_helper/panel.rb', line 43 def header(args = {}, &block) id = args.fetch(:id, '') klass = args.fetch(:class, '') content_tag(:div, id: id, class: 'panel-heading ' + klass) do content_tag(:h3, class: 'panel-title', &block) end end |
#to_s ⇒ String
Used to render the html for the entire panel object.
84 85 86 87 88 |
# File 'lib/bootstrap3_helper/panel.rb', line 84 def to_s content_tag :div, id: @id, class: container_classes, data: @data do @content.call(self) end end |