Sha256: 32c4f287430689cc03055f19b5c09f9d8067d512bbdb1dee052821b6b1e27ae9

Contents?: true

Size: 607 Bytes

Versions: 2

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

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

  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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fomantic-ui-sass-2.9.3.2 app/helpers/semantic_flash_helper.rb
fomantic-ui-sass-2.9.3.1 app/helpers/semantic_flash_helper.rb