Class: Para::Markup::Alert

Inherits:
Component show all
Defined in:
lib/para/markup/alert.rb

Instance Attribute Summary

Attributes inherited from Component

#view

Instance Method Summary collapse

Methods inherited from Component

#initialize

Constructor Details

This class inherits a constructor from Para::Markup::Component

Instance Method Details

#container(message, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/para/markup/alert.rb', line 4

def container(message, options = {}, &block)
  if block
    options = message
    message = capture { block.call }
  end

  type = options.delete(:type) || 'info'

  merge_class!(options, "alert")
  merge_class!(options, "alert-#{ type }")

  dismissable = !options.key?(:dismissable) || options.delete(:dismissable)

  merge_class!(options, "alert-dismissable") if dismissable

   :div, options do
    if dismissable
      close_button + message
    else
      message
    end
  end
end