Module: TwitterBootstrapHelpers::ViewHelpers
- Defined in:
- lib/twitter-bootstrap-helpers/view_helpers.rb
Instance Method Summary collapse
- #alert_close_tag ⇒ Object
- #alert_heading_tag(heading) ⇒ Object
- #alert_message(opts = {}, &block) ⇒ Object
- #icon_for(icon_name, string = '', icon_position = :left) ⇒ Object
Instance Method Details
#alert_close_tag ⇒ Object
33 34 35 36 37 |
# File 'lib/twitter-bootstrap-helpers/view_helpers.rb', line 33 def alert_close_tag content_tag(:a, :class => 'close', :data => {:dismiss => 'alert'}) do raw('×') end end |
#alert_heading_tag(heading) ⇒ Object
39 40 41 |
# File 'lib/twitter-bootstrap-helpers/view_helpers.rb', line 39 def alert_heading_tag(heading) contents = content_tag(:h4, heading, :class => 'alert-heading') end |
#alert_message(opts = {}, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/twitter-bootstrap-helpers/view_helpers.rb', line 14 def (opts = {}, &block) alert_classes = ["alert"] alert_classes << "alert-#{opts[:type]}" if opts[:type] alert_classes << opts[:class] if opts[:class] contents = capture(&block) if opts[:heading] alert_classes << "alert-block" contents = alert_heading_tag(opts[:heading]) + contents end if opts[:show_close_button] contents = alert_close_tag + contents end content_tag :div, contents, :class => alert_classes.join(' ') end |
#icon_for(icon_name, string = '', icon_position = :left) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/twitter-bootstrap-helpers/view_helpers.rb', line 3 def icon_for(icon_name, string = '', icon_position = :left) classes = ["icon-#{icon_name}"] if string.present? classes << 'on-left' if icon_position == :left classes << 'on-right' if icon_position == :right end icon = content_tag(:i, '', :class => classes) html = (icon_position == :left) ? icon << string : string << icon raw(html) end |