Sha256: 57cd9567f2fa1a1dbad3175851a39278afaa45bb034c0fcb5e29050529295852

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/transform_values'

module RailsStuff
  module Helpers
    module Bootstrap
      BOOTSTRAP_FLASH_TYPE = {
        success:  'alert-success',
        error:    'alert-danger',
        alert:    'alert-warning',
        notice:   'alert-info',
      }.stringify_keys.freeze

      def flash_messages
        flash.map do |type, message|
          content_tag :div, class: [:alert, BOOTSTRAP_FLASH_TYPE[type] || type] do
            content_tag(:button, '×'.html_safe, class: :close, data: {dismiss: :alert}) +
              simple_format(message)
          end
        end.join.html_safe
      end

      ICONS = {
        destroy:  %(<span class='glyphicon icon-destroy'></span>),
        edit:     %(<span class='glyphicon icon-edit'></span>),
        new:      %(<span class='glyphicon icon-add'></span>),
      }.tap { |x| x.transform_values!(&:html_safe) if ''.respond_to?(:html_safe) }

      def basic_link_icons
        ICONS
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_stuff-0.6.0.rc1 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.5.1 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.5.0 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.4.0 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.3.0 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.2.0 lib/rails_stuff/helpers/bootstrap.rb
rails_stuff-0.1.0 lib/rails_stuff/helpers/bootstrap.rb