Module: SemanticFlashHelper

Defined in:
app/helpers/semantic_flash_helper.rb

Constant Summary collapse

ALERT_TYPES =
%i[error info success warning].freeze

Instance Method Summary collapse

Instance Method Details

#flash_container(type, message) ⇒ Object



19
20
21
22
23
# File 'app/helpers/semantic_flash_helper.rb', line 19

def flash_container(type, message)
  (:div, class: "ui #{type} message") do
    (:i, '', class: 'close icon') + message
  end
end

#semantic_flashObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/semantic_flash_helper.rb', line 4

def semantic_flash
  output = ''
  flash.each do |type, message|
    next if message.blank?

    type = :success if type.to_sym == :notice
    type = :error   if type.to_sym == :alert
    next unless ALERT_TYPES.include?(type.to_sym)

    output += flash_container(type, message)
  end

  raw(output)
end