Class: Booties::Panel
- Inherits:
-
Object
- Object
- Booties::Panel
- Extended by:
- Forwardable
- Includes:
- Utils
- Defined in:
- lib/booties/panel.rb
Instance Method Summary collapse
-
#body(content = nil, &block) ⇒ Object
Renders the panel body.
-
#footer(content = nil, &block) ⇒ Object
Renders the panel footer.
-
#heading(content = nil, &block) ⇒ Object
Renders the panel heading.
-
#initialize(view_context, context: :default, **options) ⇒ Panel
constructor
Instantiates a new Panel.
-
#render(&block) ⇒ Object
Renders the top-level div for the panel.
-
#title(content = nil, &block) ⇒ Object
Renders the panel title.
Methods included from Utils
Constructor Details
#initialize(view_context, context: :default, **options) ⇒ Panel
Instantiates a new Panel. Several helper methods like #content_tag will be delegated to view_context. The optional context argument can be passed in to specify the panel context. context defaults to :default. Any additional options will be included as attributes on the top-level panel div.
14 15 16 17 18 |
# File 'lib/booties/panel.rb', line 14 def initialize(view_context, context: :default, **) @view_context = view_context @context = context = end |
Instance Method Details
#body(content = nil, &block) ⇒ Object
Renders the panel body. The content of the body can be passed in through the content parameter or as a block.
54 55 56 57 |
# File 'lib/booties/panel.rb', line 54 def body(content = nil, &block) content ||= capture &block content_tag :div, content, class: 'panel-body' end |
#footer(content = nil, &block) ⇒ Object
Renders the panel footer. The content of the footer can be passed in through the content parameter or as a block.
62 63 64 65 |
# File 'lib/booties/panel.rb', line 62 def (content = nil, &block) content ||= capture &block content_tag :div, content, class: 'panel-footer' end |
#heading(content = nil, &block) ⇒ Object
Renders the panel heading. The content of the heading can be passed in through the content parameter or as a block.
38 39 40 41 |
# File 'lib/booties/panel.rb', line 38 def heading(content = nil, &block) content ||= capture &block content_tag :div, content, class: 'panel-heading' end |
#render(&block) ⇒ Object
Renders the top-level div for the panel. @context is used to specify the panel’s context. The content is captured from block. The Panel object will be passed as a parameter to block.
26 27 28 29 30 31 32 33 |
# File 'lib/booties/panel.rb', line 26 def render(&block) = .dup classes = merge_classes %W[panel panel-#@context], .delete(:class) content_tag :div, class: classes, ** do capture self, &block end end |
#title(content = nil, &block) ⇒ Object
Renders the panel title. The content of the title can be passed in through the content paramter or as a block.
46 47 48 49 |
# File 'lib/booties/panel.rb', line 46 def title(content = nil, &block) content ||= capture &block content_tag :h3, content, class: 'panel-title' end |