Sha256: 01299a6718c9f57f81def05f38948eac1755135c4048c781c489686c1c8dcd68
Contents?: true
Size: 756 Bytes
Versions: 35
Compression:
Stored size: 756 Bytes
Contents
# frozen_string_literal: true module BootstrapFlashHelper ALERT_TYPES_MAP = { notice: :success, alert: :danger, error: :danger, info: :info, warning: :warning }.freeze def bootstrap_flash safe_join(flash.each_with_object([]) do |(type, message), messages| next if message.blank? || !message.respond_to?(:to_str) type = ALERT_TYPES_MAP.fetch(type.to_sym, type) messages << flash_container(type, message) end, "\n").presence end def flash_container(type, message) content_tag :div, class: "alert alert-#{type} alert-dismissable" do button_tag type: 'button', class: 'close', data: { dismiss: 'alert' } do '×'.html_safe end.safe_concat(message) end end end
Version data entries
35 entries across 35 versions & 1 rubygems