Module: RailsStuff::Helpers::Bootstrap

Included in:
All
Defined in:
lib/rails_stuff/helpers/bootstrap.rb

Constant Summary collapse

BOOTSTRAP_FLASH_TYPE =
{
  success:  'alert-success',
  error:    'alert-danger',
  alert:    'alert-warning',
  notice:   'alert-info',
}.stringify_keys.freeze
CROSS =

rubocop:disable Rails/OutputSafety

'×'.html_safe.freeze
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) }

Instance Method Summary collapse

Instance Method Details



32
33
34
# File 'lib/rails_stuff/helpers/bootstrap.rb', line 32

def basic_link_icons
  ICONS
end

#flash_messagesObject



16
17
18
19
20
21
22
23
24
# File 'lib/rails_stuff/helpers/bootstrap.rb', line 16

def flash_messages
  messages = flash.map do |type, message|
     :div, class: [:alert, BOOTSTRAP_FLASH_TYPE[type] || type] do
      (:button, CROSS, class: :close, data: {dismiss: :alert}) +
        simple_format(message)
    end
  end
  safe_join(messages)
end