Sha256: d4ed3ff1e344070a5dc72aea5de94c2817e3959fbf961922ec316c1b3ab3a094

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

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)
        
        messages = []
        flash.each do |key, value|
          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 = link_to(raw("×"), "#", :class => "close", :data => { :dismiss => "alert" })
          end
          
          messages << content_tag(:div, :class => "alert alert-#{key} #{"alert-block" if block}") do
            close + heading + " " + value
          end
        end
        raw(messages.join)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bootstrap_flash_messages-0.0.4 lib/bootstrap_flash_messages/helpers.rb
bootstrap_flash_messages-0.0.3 lib/bootstrap_flash_messages/helpers.rb
bootstrap_flash_messages-0.0.2 lib/bootstrap_flash_messages/helpers.rb