Module: TwitterBootstrap::Helpers
- Includes:
- ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/twitter_bootstrap_helpers.rb
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
-
#generate_menu_item(item) ⇒ Object
generate_menu_item :divider.
-
#generate_menu_items(items, ul_class = :nav) ⇒ Object
generate_menu_items [ { :link => ‘#’, :title => ‘Menu item’ } ].
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
6 7 8 |
# File 'lib/twitter_bootstrap_helpers.rb', line 6 def output_buffer @output_buffer end |
Instance Method Details
#generate_menu_item(item) ⇒ Object
generate_menu_item :divider
<li class='divider' />
generate_menu_item :link => ‘#’,
:title => 'Menu item',
:active => true,
:items => [
{
*some_options*
}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/twitter_bootstrap_helpers.rb', line 23 def (item) return tag :li, :class => 'divider-vertical' if item == :divider = {} li_class = item[:li_class] ? [item[:li_class]] : [] li_class << :active if item[:active] li_class << :dropdown if item[:items] = {} [:class] = item[:link_class] ? [item[:link_class]] : [] if item[:items] [:class] << 'dropdown-toggle' [:data] = { :toggle => :dropdown } end li_class = li_class.blank? ? nil : { :class => li_class.join(' ') } content_tag :li, li_class, false do inner = link_to item[:title], item[:link], inner << ( item[:items], 'dropdown-menu' ) if item[:items] inner end end |
#generate_menu_items(items, ul_class = :nav) ⇒ Object
generate_menu_items [
{
:link => '#',
:title => 'Menu item'
}
]
60 61 62 63 64 65 66 |
# File 'lib/twitter_bootstrap_helpers.rb', line 60 def (items, ul_class=:nav) return '' unless items content_tag(:ul, :class => ul_class) do items = items.values if items.is_a? Hash items.map { |i| (i) }.join.html_safe end end |