Class: Spurs::Nav::Builder
- Inherits:
-
Object
- Object
- Spurs::Nav::Builder
- 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
-
#dropdown(name, options = { }) ⇒ Object
Create a dropdown *options :label => overrides display name.
-
#initialize(controller, opts = { }) ⇒ Builder
constructor
A new instance of Builder.
- #list_header(name) ⇒ Object
-
#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’].
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
#dropdown(name, options = { }) ⇒ Object
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, ={ }) opts = .merge({ :dropdown => true }) actions = [:actions] ? [:actions] : [] tab_tag(name, content_tag_string(:b, '', :class => "caret").html_safe, (actions).html_safe, opts) end |
#list_header(name) ⇒ Object
37 38 39 |
# File 'lib/spurs/nav/builder.rb', line 37 def list_header(name) content_tag(: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, ={ }) tab_tag(name, nil, nil, ) end |