Module: RailsBootstrapHelpers::Helpers::AlertHelper
- Defined in:
- lib/rails-bootstrap-helpers/helpers/alert_helper.rb
Instance Method Summary collapse
-
#bs_alert(text, options = {}) ⇒ Object
Renders a Bootstrap alert with the given text.
Instance Method Details
#bs_alert(text, options = {}) ⇒ Object
Renders a Bootstrap alert with the given text.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rails-bootstrap-helpers/helpers/alert_helper.rb', line 15 def bs_alert (text, = {}) = .deep_dup cls = "alert" type = .delete(:type) if type ActiveSupport::Deprecation.warn "Usage of the option `:type` is deprecated. Please use the `:style` option instead" end if style = .delete(:style) || type style = style.to_s if style == "notice" style = "success" end unless style == "warning" || style == "default" cls << " alert-#{style}" end end if style = .delete(:block) cls << " alert-block" end append_class!(, cls) if .delete(:dismiss_button) content_tag :div, class: cls do = content_tag :button, "×", type: "button", class: "close", :"data-dismiss" => "alert" + text end else content_tag :div, text, end end |