Class: Bootstrap4RailsComponents::Bootstrap::Components::Alert

Inherits:
Base
  • Object
show all
Includes:
Utilities::Dismissible, Utilities::Headable, Utilities::Themeable
Defined in:
lib/bootstrap4_rails_components/bootstrap/components/alert.rb

Overview

Bootstrap Alert Component getbootstrap.com/docs/4.1/components/alerts/

Instance Attribute Summary

Attributes inherited from Base

#body, #options, #view_context

Instance Method Summary collapse

Methods included from Utilities::Themeable

#outlined, #theme

Methods included from Utilities::Headable

#heading

Methods included from Utilities::Dismissible

#dismissible

Methods inherited from Base

#component_family, #component_initialize, #data, #href, #html_options, #id, #initialize, #style, #utility_initialize

Constructor Details

This class inherits a constructor from Bootstrap4RailsComponents::Bootstrap::Components::Base

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bootstrap4_rails_components/bootstrap/components/alert.rb', line 13

def render
  (:div, html_options) do
    capture do
      if dismissible
        concat(
          Bootstrap4RailsComponents::Bootstrap::Components::Button.new({ as: :button, class: 'close', theme: nil, data: { dismiss: 'alert' }, aria: { label: 'Close' } }, view_context).render do
            (:span, "×".html_safe, aria: { hidden: 'true' } )
          end
        )
      end
      if heading
        concat((:h4, heading, class: 'alert-heading'))
      end
      concat(block_given? ? yield : body)
    end
  end
end