Module: Bootstrap::AlertHelper
- Defined in:
- app/helpers/bootstrap/alert_helper.rb
Overview
Rails helpers for producing Bootstrap alert boxes.
Constant Summary collapse
- ALERT_ATTRIBUTES =
%w(error success info block)
Instance Method Summary collapse
-
#alert(text, alert_type, options = {}) ⇒ String
Returns html for alert.
-
#alert_close(show = true) ⇒ String
Return an alert box close button.
-
#alert_heading(heading) ⇒ String
Return an alert heading.
Instance Method Details
#alert(text, alert_type, options = {}) ⇒ String
Returns html for alert
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/bootstrap/alert_helper.rb', line 30 def alert(*args, &block) text = args.shift unless block_given? = (args.) = ensure_class(, 'alert') = add_alert_classes(, args) heading = .delete(:heading) show_close = .delete(:close) != false if block_given? content_tag(:div, ) do alert_close(show_close) + alert_heading(heading) + capture(&block) end else content_tag(:div, ) do alert_close(show_close) + alert_heading(heading) + text end end end |
#alert_close(show = true) ⇒ String
Return an alert box close button
56 57 58 59 |
# File 'app/helpers/bootstrap/alert_helper.rb', line 56 def alert_close(show=true) return '' unless show content_tag(:button, '×'.html_safe, class: 'close', data: {dismiss: 'alert'}) end |
#alert_heading(heading) ⇒ String
Return an alert heading
64 65 66 67 |
# File 'app/helpers/bootstrap/alert_helper.rb', line 64 def alert_heading(heading) return '' unless heading.present? content_tag(:h4, heading) end |