Sha256: f9fdd2688ee3005b933bcd1c8e3bf7efd31247a145100a02547c9b433c560fc7

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module BootstrapFlashMessages
  module Helpers
    def flash_messages(*args)
      if flash.present?
        block = args.include?(:block)
        show_heading = args.include?(:heading)
        show_close = args.include?(:close)
        unescape_html = args.include?(:html)
        simple_format = args.include?(:simple_format)
        fade = args.include?(:fade)
        fade_in = args.include?(:fade_in)
        
        messages = []
        flash.each do |key, value|
          next if key == :timedout
          
          heading = ""
          if show_heading
            heading_text = I18n.t("flash_messages.headings.#{key}")
            heading = (block ? content_tag(:h4, heading_text, :class => "alert-heading") : content_tag(:strong, heading_text))
          end
          close = ""
          if show_close
            close = content_tag(:button, raw("×"), :type => "button", :class => "close", "data-dismiss" => "alert", "aria-hidden" => "true")
          end
          
          value = simple_format(value) if simple_format
          value = raw(value) if unescape_html
          
          messages << content_tag(:div, close + heading + " " + value, :class => "alert alert-#{BootstrapFlashMessages.alert_class_mapping(key)}#{' alert-dismissable' if show_close}#{" fade#{" in" unless fade_in}" if fade || fade_in}")
        end
        
        raw(messages.join)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap_flash_messages-1.0.2 lib/bootstrap_flash_messages/helpers.rb