Module: Bh::AlertHelper

Includes:
BaseHelper
Defined in:
lib/bh/helpers/alert_helper.rb

Instance Method Summary collapse

Instance Method Details

#alert_box(message_or_options_with_block = nil, options = nil, &block) ⇒ String

Returns an HTML block tag that follows the Bootstrap documentation on how to display alert boxes. Alert boxes provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. The message to display in the alert can either be passed as the first parameter (in which case, the options are the second parameter), or as a block (in which case, the options are the first parameter).

Examples:

An alert with a plain-text message passed as the first parameter.

alert 'User updated successfully', dismissible: true

An alert with an HTML message passed as a block.

alert_box dismissible: true do
   :strong, "User updated successfully"
end

Options Hash (options):

  • :dismissible (Boolean) — default: false

    whether to display an '×' to the right of the alert than can be clicked to dismiss the alert.

  • :context (#to_s) — default: :info

    the contextual alternative to apply to the alert depending on its importance. Can be :success, :info, :warning or :danger.

  • :priority (#to_s)

    if the alert box is used to show a Rails flash message, the priority of the message. Can be :alert or :notice.

See Also:



34
35
36
37
38
39
40
# File 'lib/bh/helpers/alert_helper.rb', line 34

def alert_box(message_or_options_with_block = nil, options = nil, &block)
  if block_given?
    alert_string capture_alert(&block), message_or_options_with_block || {}
  else
    alert_string message_or_options_with_block, options || {}
  end
end