Module: FlashHelper
- Defined in:
- lib/flash_notifier/flash_helper.rb
Instance Method Summary collapse
Instance Method Details
#build_bootstrap_flash ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flash_notifier/flash_helper.rb', line 12 def build_bootstrap_flash alert_klasses = { success: 'alert-success', error: 'alert-danger', alert: 'alert-warning', notice: 'alert-info' } html = '' flash.each do |type, | html += content_tag :div, class: "alert #{alert_klasses[type.to_sym] || type.to_s} alert-dismissible fade in", role: 'alert' do inner_html = link_to 'x', '#', class: 'close', data: {dismiss: 'alert'}, aria_label: 'close', title: 'close' inner_html += content_tag :div, , class: 'text' inner_html.html_safe end end html.html_safe end |
#build_flash(*args) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/flash_notifier/flash_helper.rb', line 2 def build_flash *args = args.last.is_a?(::Hash) ? args.pop.with_indifferent_access : {} html = content_tag(:div, '', data: { flash_notifier_options: }) flash.each do |type, | flash_type = (%w(notice success).include?(type)) ? 'success' : (( %w(alert error).include?(type)) ? 'error' : (%w(warning info).include?(type) ? type : 'info' )) html += content_tag(:div, '' , data: { flash_notifier: 'inside gem', flash_type: flash_type, flash_msg: }) end html.html_safe end |