Sha256: ae938338b3b6e22aff77e1c3ec0c668fd6140a8f288990cc5e50b4eebb1e4991

Contents?: true

Size: 967 Bytes

Versions: 1

Compression:

Stored size: 967 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("x", "#", :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

1 entries across 1 versions & 1 rubygems

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