Sha256: fd94afa7ae672838f45692f641b1410dd36ecfb74000b2f950b4bb76299e596e

Contents?: true

Size: 913 Bytes

Versions: 20

Compression:

Stored size: 913 Bytes

Contents

# = bootstrap_flash
module BootstrapFlashHelper
  ALERT_TYPES = [:success, :info, :warning, :danger] unless const_defined?(:ALERT_TYPES)

  def bootstrap_flash(options = {})
    flash_messages = []
    flash.each do |type, message|
      # Skip empty messages, e.g. for devise messages set to nothing in a locale file.
      next if message.blank?

      type = type.to_sym
      type = :success if type == :notice
      type = :danger  if type == :alert
      type = :danger  if type == :error
      next unless ALERT_TYPES.include?(type)

      Array(message).each do |msg|
        text = content_tag(:div,
                           content_tag(:button, raw("×"), class: "close", "data-dismiss" => "alert") +
                           msg, class: "alert fade in alert-#{type} #{options[:class]}")
        flash_messages << text if msg
      end
    end
    flash_messages.join("\n").html_safe
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
teleporter-2.0.11 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.10 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.9 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.8 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.7 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.6 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.4 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.2 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.1 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-2.0.0 lib/generators/teleport/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.2.4 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.2.3 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.2.2 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.2.1 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.1.1 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.1.0 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.0.2 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.0.1 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-1.0.0 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb
teleporter-0.1.0 lib/generators/initial/templates/bootstrap/bootstrap_flash_helper.rb