class Bootstrap::ViewHelpers::Components::Alert

Public Instance Methods

dismissible?() click to toggle source

Defaults to false

# File lib/bootstrap/view_helpers/components/alert.rb, line 19
def dismissible?
  options[:dismissible]
end
fade?() click to toggle source

Defaults to true

# File lib/bootstrap/view_helpers/components/alert.rb, line 24
def fade?
  return true if options[:fade].nil?
  options[:fade]
end
to_html() click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 5
def to_html
  content_tag(:div, options) do
    concat(options[:content]) if options[:content]
    concat close_button
    block.call(self) if block.present?
  end
end

Protected Instance Methods

close_button() click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 57
def close_button
  return unless dismissible?
  content_tag(:button, class: 'close', data: { dismiss: 'alert' },
              aria: { label: 'Close' }) do
    content_tag(:span, '×', aria: { hidden: true })
  end
end
container_options() click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 50
def container_options
  default = { class: "alert alert-#{style}#{' fade show' if fade?} " }
  default[:class] << 'alert-dismissible ' if dismissible?
  default[:class] << options.delete(:class) if options[:class]
  default.merge(options)
end
defaults() click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 31
def defaults
  { style: ContextualClasses::SECONDARY }
end
inject_class_name() click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 42
def inject_class_name
  class_name = "alert alert-#{style} "
  class_name << 'alert-dismissible ' if dismissible?
  class_name << 'fade show ' if fade?
  class_name << options.delete(:class) if options[:class]
  options[:class] = class_name
end
parse_options(_) click to toggle source
# File lib/bootstrap/view_helpers/components/alert.rb, line 35
def parse_options(_)
  super
  inject_class_name
  options[:role] = 'alert'
  options[:style] = options[:html_style]
end