Module: Shoehorn::Helpers::AlertHelpers

Defined in:
lib/shoehorn/helpers/alert_helpers.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_alert(message, options = {}) ⇒ Object

Renders alert message

Examples

bootstrap_alert("Hello!")
# => '<div class="alert"><a class="close">×</a>Hello!</div>'

bootstrap_alert("Hello!", type: 'error', close: false)
# => '<div class="alert alert-error">Hello!</div>'

bootstrap_alert("Content of alert", heading: "WARNING!", type: 'info')
# => '<div class="alert alert-info"><a class="close">×</a>
         <h4 class="alert-heading">WARNING!</h4>Content of alert</div>'

Returns HTML String for the alert

Parameters:

  • message (String)

    message to be displayed

  • options (Hash) (defaults to: {})

    hash containing options (default: {}): :block - The Boolean whether to display as a block (optional) :close - The Boolean whether to render close button :heading - The String heading message to render :dismiss - The Boolean whether to add dismiss attribute :type - The String type of alert to display: error, success or info :html_options - Any additional HTML options desired on the alert DIV.



29
30
31
32
33
34
# File 'lib/shoehorn/helpers/alert_helpers.rb', line 29

def bootstrap_alert(message, options = {})
  Shoehorn::Components::Alert.new(
    message,
    options
  ).to_s
end