Class: Bootstrap4Helper::Card
- Defined in:
- lib/bootstrap4_helper/card.rb
Overview
Used to build Bootstrap Card components. Cards are wildly used through Bootstrap 4.
Instance Method Summary collapse
-
#body(args = {}, &block) ⇒ String
Builds the Body component.
-
#footer(args = {}, &block) ⇒ String
Builds the Footer component.
-
#header(args = {}, &block) ⇒ String
Builds the Header component.
-
#image_overlay(args = {}, &block) ⇒ String
Builds a Img Overlay component.
-
#initialize(template, opts = {}, &block) ⇒ Card
constructor
Used to initialize a new Card component.
-
#text(args = {}, &block) ⇒ String
Builds a Text component.
-
#title(args = {}, &block) ⇒ String
Builds a Title component.
-
#to_s ⇒ String
Outputs the Object in its String representation.
Methods inherited from Component
#capture, #concat, #config, #content_tag, #parse_arguments, #uuid
Constructor Details
#initialize(template, opts = {}, &block) ⇒ Card
Used to initialize a new Card component.
15 16 17 18 19 20 21 22 |
# File 'lib/bootstrap4_helper/card.rb', line 15 def initialize(template, opts = {}, &block) super(template) @id = opts.fetch(:id, '') @class = opts.fetch(:class, '') @data = opts.fetch(:data, nil) @content = block || proc { '' } end |
Instance Method Details
#body(args = {}, &block) ⇒ String
Builds the Body component.
44 45 46 |
# File 'lib/bootstrap4_helper/card.rb', line 44 def body(args = {}, &block) build_base_component :body, args, &block end |
#footer(args = {}, &block) ⇒ String
Builds the Footer component.
56 57 58 |
# File 'lib/bootstrap4_helper/card.rb', line 56 def (args = {}, &block) build_base_component :footer, args, &block end |
#header(args = {}, &block) ⇒ String
Builds the Header component.
32 33 34 |
# File 'lib/bootstrap4_helper/card.rb', line 32 def header(args = {}, &block) build_base_component :header, args, &block end |
#image_overlay(args = {}, &block) ⇒ String
Builds a Img Overlay component.
92 93 94 |
# File 'lib/bootstrap4_helper/card.rb', line 92 def (args = {}, &block) build_base_component 'img-overlay', args, &block end |
#text(args = {}, &block) ⇒ String
Builds a Text component.
80 81 82 |
# File 'lib/bootstrap4_helper/card.rb', line 80 def text(args = {}, &block) build_sub_component config(:card_text, :p), :text, args, &block end |
#title(args = {}, &block) ⇒ String
Builds a Title component.
68 69 70 |
# File 'lib/bootstrap4_helper/card.rb', line 68 def title(args = {}, &block) build_sub_component config(:card_title, :h5), :title, args, &block end |
#to_s ⇒ String
Outputs the Object in its String representation.
100 101 102 103 104 |
# File 'lib/bootstrap4_helper/card.rb', line 100 def to_s content_tag :div, id: @id, class: "card #{@class}", data: @data do @content.call(self) end end |