def render_alert(type, message, array_auto_hide = nil)
      return nil if message.blank?

      if type.to_s =~ /\Asafe_/
        type = type.to_s[5..-1]
        message = message.to_s.html_safe
      end

      type = type.to_sym

      type = :info if type == :notice
      type = :danger if type == :alert
      type = :danger if type == :error
      type = :warning if type == :warn

      type = :info unless [:info, :success, :danger, :warning].include?(type)

      array_auto_hide = nil unless array_auto_hide.is_a?(::Integer) && array_auto_hide > 0

      contents = render_alert_message(message, array_auto_hide)

      html =
      "<div class=\"alert alert-#{type} alert-dismissible\">" +
          '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
          contents[:text]

      unless contents[:script].blank?
        html += <<-EOS
<script type="text/javascript">
<![CDATA[
#{contents[:script]}
]]>
</script>
        EOS
      end

      html += '</div>'

      html.html_safe
    end
def render_alert(type, message, array_auto_hide = nil)
      return nil if message.blank?

      if type.to_s =~ /\Asafe_/
        type = type.to_s[5..-1]
        message = message.to_s.html_safe
      end

      type = type.to_sym

      type = :info if type == :notice
      type = :danger if type == :alert
      type = :danger if type == :error
      type = :warning if type == :warn

      type = :info unless [:info, :success, :danger, :warning].include?(type)

      array_auto_hide = nil unless array_auto_hide.is_a?(::Integer) && array_auto_hide > 0

      contents = render_alert_message(message, array_auto_hide)

      html =
      "<div class=\"alert alert-#{type} alert-dismissible\">" +
          '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
          contents[:text]

      unless contents[:script].blank?
        html += <<-EOS
<script type="text/javascript">
<![CDATA[
#{contents[:script]}
]]>
</script>
        EOS
      end

      html += '</div>'

      html.html_safe
    end
Renders a dismissible alert message.

 The +type+ can be :info, :notice, :success, :danger, :alert, or :warning.
 Optionally, you can prefix the +type+ with 'safe_'.
 This tells the system that the message you are passing is HTML safe and does not need to be escaped.
 If you want to include HTML (ie - <br>) in your message, you need to ensure it is actually safe and
 set the type as :safe_info, :safe_notice, :safe_success, :safe_danger, :safe_alert, or :safe_warning.

 The +message+ is the data you want to display.
 * Safe messages must be String values.  No processing is done on safe messages.
 * Unsafe messages can be a Symbol, a String, an Array, or a Hash.
   * An array can contain Symbols, Strings, Arrays, or Hashes.
     * Each subitem is processed individually.
     * Arrays within arrays are essentially flattened into one array.
   * A Hash is converted into an unordered list.
     * The keys should be either Symbols or Strings.
     * The values can be Symbols, Strings, Arrays, or Hashes.
   * A Symbol will be converted into a string, humanized, and capitalized.
   * A String will be escaped for HTML, rendered for Markdown, and then returned.
     * The Markdown will allow you to customize simple strings by adding some basic formatting.

 Finally, there is one more parameter, +array_auto_hide+, that can be used to tidy up otherwise
 long alert dialogs.  If set to a positive integer, this is the maximum number of items to show initially from any
 array. When items get hidden, a link is provided to show all items.
 This is particularly useful when you have a long list of errors to show to a user, they will then be able
 to show all of the errors if they desire.

     # render_alert :info, 'Hello World'
     <div class="alert alert-info alert-dismissible">
       <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       <span>Hello World</span>
     </div>

     # render_alert :success, [ 'Item 1 was successful.', 'Item 2 was successful' ]
     <div class="alert alert-info alert-dismissible">
       <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       <span>Item 1 was successful.</span><br>
       <span>Item 2 was successful.</span>
     </div>

     # render_alert :error, { :name => [ 'cannot be blank', 'must be unique' ], :age => 'must be greater than 18' }
     <div class="alert alert-info alert-dismissible">
       <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       <div>
         Name
         <ul>
           <li>cannot be blank</li>
           <li>must be unique</li>
         </ul>
       </div>
       <div>
         Age
         <ul>
           <li>must be greater than 18</li>
         </ul>
       </div>
     </div>

     # render_alert :error, [ '__The model could not be saved.__', { :name => [ 'cannot be blank', 'must be unique' ], :age => 'must be greater than 18' } ]
     <div class="alert alert-info alert-dismissible">
       <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       <span><strong>The model could not be saved.</strong></span><br>
       <div>
         Name
         <ul>
           <li>cannot be blank</li>
           <li>must be unique</li>
         </ul>
       </div>
       <div>
         Age
         <ul>
           <li>must be greater than 18</li>
         </ul>
       </div>
     </div>