Class: Spurs::Nav::Builder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::ControllerHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
Defined in:
lib/spurs/nav/builder.rb

Constant Summary collapse

@@default_tab_options =
{
    :icon_only => false
}
@@default_dropdown_options =
{
    :href      => "#",
    :method    => :get,
    :icon_only => false
}

Instance Method Summary collapse

Constructor Details

#initialize(controller, opts = { }) ⇒ Builder

Returns a new instance of Builder.



20
21
22
23
# File 'lib/spurs/nav/builder.rb', line 20

def initialize(controller, opts={ })
  @args_from_helper = opts.clone
  assign_controller(controller)
end

Instance Method Details

Create a dropdown *options :label => overrides display name



44
45
46
47
48
49
# File 'lib/spurs/nav/builder.rb', line 44

def dropdown(name, options={ })
  opts    = options.merge({ :dropdown => true })
  actions = options[:actions] ? options[:actions] : []
  tab_tag(name, (:b, '', :class => "caret").html_safe, build_drop_down_menu(actions).html_safe, opts)

end

#list_header(name) ⇒ Object



37
38
39
# File 'lib/spurs/nav/builder.rb', line 37

def list_header(name)
  (:li, name, :class => 'nav-header')
end

#tab(name, options = { }) ⇒ Object

Create a tab *options :label => overrides display name :href => link for tab :onclick => onclick for tab *active :active => true will force the tab to be active :active => [=> ‘pages’, :action => ‘index’,=> ‘pages’, :action => ‘new’]



33
34
35
# File 'lib/spurs/nav/builder.rb', line 33

def tab(name, options={ })
  tab_tag(name, nil, nil, options)
end