menu_helper 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,205 +1,203 @@
1
- module PluginAWeek #:nodoc:
2
- module MenuHelper
3
- # Represents a group of menus. A menu bar can either be the main menu bar
4
- # or a menu bar nested within a menu.
5
- class MenuBar < HtmlElement
6
- # The css class to apply for all menu bars
7
- cattr_accessor :menu_bar_class
8
- @@menu_bar_class = 'menubar'
1
+ module MenuHelper
2
+ # Represents a group of menus. A menu bar can either be the main menu bar
3
+ # or a menu bar nested within a menu.
4
+ class MenuBar < HtmlElement
5
+ # The css class to apply for all menu bars
6
+ cattr_accessor :menu_bar_class
7
+ @@menu_bar_class = 'menubar'
8
+
9
+ # The css class to apply when a sub-menu bar is selected
10
+ cattr_accessor :selected_class
11
+ @@selected_class = 'menubar-selected'
12
+
13
+ # The request context in which this menu bar is being rendered
14
+ attr_reader :request_controller
15
+
16
+ # The menus within this menu bar
17
+ attr_reader :menus
18
+
19
+ # The configuration options for this menu bar
20
+ attr_reader :options
21
+
22
+ def initialize(request_controller, options = {}, html_options = {}) #:nodoc:
23
+ super(html_options)
9
24
 
10
- # The css class to apply when a sub-menu bar is selected
11
- cattr_accessor :selected_class
12
- @@selected_class = 'menubar-selected'
25
+ # Set up default options
26
+ options.assert_valid_keys(:parent_menu, :auto_set_ids, :attach_active_submenus, :content_for)
27
+ options.reverse_merge!(:auto_set_ids => true, :attach_active_submenus => true, :content_for => 'menu_bar')
28
+ @options = options
13
29
 
14
- # The request context in which this menu bar is being rendered
15
- attr_reader :request_controller
30
+ # Set context of the menu bar (the request and any parent)
31
+ @request_controller = request_controller
16
32
 
17
- # The menus within this menu bar
18
- attr_reader :menus
33
+ # No menus initially associated
34
+ @menus = []
19
35
 
20
- # The configuration options for this menu bar
21
- attr_reader :options
36
+ # Set up default html options
37
+ self[:class] = "#{self[:class]} #{menu_bar_class} #{menu_bar_class}-#{level}".strip
22
38
 
23
- def initialize(request_controller, options = {}, html_options = {}) #:nodoc:
24
- super(html_options)
25
-
26
- # Set up default options
27
- options.assert_valid_keys(:parent_menu, :auto_set_ids, :attach_active_submenus, :content_for)
28
- options.reverse_merge!(:auto_set_ids => true, :attach_active_submenus => true, :content_for => 'menu_bar')
29
- @options = options
30
-
31
- # Set context of the menu bar (the request and any parent)
32
- @request_controller = request_controller
33
-
34
- # No menus initially associated
35
- @menus = []
36
-
37
- # Set up default html options
38
- self[:class] = "#{self[:class]} #{menu_bar_class} #{menu_bar_class}-#{level}".strip
39
+ yield self if block_given?
40
+ end
41
+
42
+ # Gets the nesting level of this menu bar. The top-level menu bar will
43
+ # always have a nesting level of 1.
44
+ def level
45
+ @level ||= begin
46
+ level = 1
39
47
 
40
- yield self if block_given?
41
- end
42
-
43
- # Gets the nesting level of this menu bar. The top-level menu bar will
44
- # always have a nesting level of 1.
45
- def level
46
- @level ||= begin
47
- level = 1
48
-
49
- # Keep walking up the tree, until first-level menus are encountered
50
- menu = parent_menu
51
- while menu
52
- level += 1
53
- menu = menu.parent_menu
54
- end
55
-
56
- level
48
+ # Keep walking up the tree, until first-level menus are encountered
49
+ menu = parent_menu
50
+ while menu
51
+ level += 1
52
+ menu = menu.parent_menu
57
53
  end
54
+
55
+ level
58
56
  end
57
+ end
58
+
59
+ # The menu in which this menu bar is being displayed. This will be nil if
60
+ # this is the main menu bar.
61
+ def parent_menu
62
+ @options[:parent_menu]
63
+ end
64
+
65
+ # Shoulds elements have default ids automatically applied to them?
66
+ def auto_set_ids?
67
+ @options[:auto_set_ids]
68
+ end
69
+
70
+ # Should menu bars in sub-menus be attached to this menu bar?
71
+ def attach_active_submenus?
72
+ @options[:attach_active_submenus]
73
+ end
74
+
75
+ # The instance variable to use when rendering the current active sub-menu
76
+ # bar
77
+ def content_for_variable
78
+ "@content_for_#{@options[:content_for]}_level_#{level}"
79
+ end
80
+
81
+ # Is this menu bar selected? A menu bar is considered selected if it has
82
+ # a parent menu and that parent menu is selected.
83
+ def selected?
84
+ parent_menu && menus.any? {|menu| menu.selected?}
85
+ end
86
+
87
+ # Creates a new menu in this bar with the given id. The content
88
+ # within the menu is, by default, set to a humanized version of the id.
89
+ #
90
+ # == URLs with routes
91
+ #
92
+ # If you have named routes set up in the application, the menu attempts
93
+ # to automatically figure out what URL you're trying to link to. It
94
+ # does this by looking at the id of the menu and the id of its parent.
95
+ #
96
+ # For example, a menu bar with the id 'home' and a menu with the id
97
+ # 'contact_us' will attempt to look for the following named routes as
98
+ # the URL to link to (in order of priority):
99
+ # 1. home_contact_us_url
100
+ # 2. contact_us_url
101
+ #
102
+ # Example routes.rb:
103
+ #
104
+ # ActionController::Routing::Routes.draw do |map|
105
+ # map.with_options(:controller => 'home') do |home|
106
+ # home.home '', :action => 'index'
107
+ # home.home_search 'search', :action => 'search'
108
+ # end
109
+ #
110
+ # map.with_options(:controller => 'about_us') do |about_us|
111
+ # about_us.about_us 'about_us', :action => 'index'
112
+ # end
113
+ # end
114
+ #
115
+ # Example menu bar:
116
+ #
117
+ # menu_bar :home do |home|
118
+ # home.menu :about_us # => Links to about_us_url
119
+ # home.menu :search # => Links to home_search_url
120
+ # end
121
+ #
122
+ # == URLs with url_for
123
+ #
124
+ # If neither of these named routes are being used, the url will be based
125
+ # on the options passed into the menu. The url_options takes the same
126
+ # values as +url_for+. By default, the name of the controller will be
127
+ # guessed in the following order:
128
+ # 1. The id of the menu ('contact_us' => ContactUsController)
129
+ # 2. The controller of the parent menu/menu bar
130
+ # 3. The request controller
131
+ #
132
+ # To override the default controller being linked to, you can explicitly
133
+ # define it like so:
134
+ # menu :contact, 'Contact Us', :controller => 'about_us'
135
+ #
136
+ # Examples:
137
+ #
138
+ # menu :home do |home|
139
+ # home.menu :about, 'About Us', :action => 'about_us' # => Links to {:controller => 'home', :action => 'about_us'}
140
+ # home.menu :who_we_are # => Links to {:controller => 'home', :action => 'who_we_are'}
141
+ # home.menu :contact_us, :controller => 'contact', :action => 'index' # => Links to {:controller => 'contact', :action => 'index'}
142
+ # home.menu :search # => Links to {:controller => 'search'}
143
+ # end
144
+ #
145
+ # You can also link to an explicit URL like so:
146
+ #
147
+ # home.menu :search, 'http://www.google.com'
148
+ #
149
+ # == Turning off links
150
+ #
151
+ # If you don't want a menu to link to a URL, you can turn off linking like
152
+ # so:
153
+ #
154
+ # home.menu :contact_us, {}, :link => false
155
+ #
156
+ # == Defining content and html attributes
157
+ #
158
+ # By default, the content within a menu will be set as a humanized
159
+ # version of the menu's id. Examples of menus which customize the
160
+ # content and/or html attributes are below:
161
+ #
162
+ # home.menu :contact # => <li id="contact"><a href="/contact">Contact</a></li>
163
+ # home.menu :contact, 'Contact Us' # => <li id="contact"><a href="/contact">Contact Us</a></li>
164
+ # home.menu :contact, {}, :class => 'pretty' # => <li id="contact" class="pretty"><a href="/contact">Contact</a></li>
165
+ # home.menu :contact, 'Get in touch!', {}, :class => 'pretty' # => <li id="contact" class="pretty"><a href="/contact">Contact Us</a></li>
166
+ #
167
+ # == Sub-menus
168
+ #
169
+ # Menus can also have their own sub-menus by passing in a block. You can
170
+ # create sub-menus in the same manner that the main menus are created.
171
+ # For example,
172
+ #
173
+ # home.menu :about do |about|
174
+ # about.menu :who_we_are
175
+ # about.menu :contact_us
176
+ # end
177
+ def menu(id, content = nil, url_options = {}, html_options = {}, &block)
178
+ menu = Menu.new(self, id, content, url_options, html_options, &block)
179
+ @menus << menu
59
180
 
60
- # The menu in which this menu bar is being displayed. This will be nil if
61
- # this is the main menu bar.
62
- def parent_menu
63
- @options[:parent_menu]
64
- end
65
-
66
- # Shoulds elements have default ids automatically applied to them?
67
- def auto_set_ids?
68
- @options[:auto_set_ids]
69
- end
70
-
71
- # Should menu bars in sub-menus be attached to this menu bar?
72
- def attach_active_submenus?
73
- @options[:attach_active_submenus]
74
- end
75
-
76
- # The instance variable to use when rendering the current active sub-menu
77
- # bar
78
- def content_for_variable
79
- "@content_for_#{@options[:content_for]}_level_#{level}"
80
- end
81
-
82
- # Is this menu bar selected? A menu bar is considered selected if it has
83
- # a parent menu and that parent menu is selected.
84
- def selected?
85
- parent_menu && menus.any? {|menu| menu.selected?}
86
- end
181
+ menu
182
+ end
183
+
184
+ # Builds the actual html of the menu bar
185
+ def html
186
+ html_options = @html_options.dup
187
+ html_options[:class] = "#{html_options[:class]} #{selected_class}".strip if selected?
87
188
 
88
- # Creates a new menu in this bar with the given id. The content
89
- # within the menu is, by default, set to a humanized version of the id.
90
- #
91
- # == URLs with routes
92
- #
93
- # If you have named routes set up in the application, the menu attempts
94
- # to automatically figure out what URL you're trying to link to. It
95
- # does this by looking at the id of the menu and the id of its parent.
96
- #
97
- # For example, a menu bar with the id 'home' and a menu with the id
98
- # 'contact_us' will attempt to look for the following named routes as
99
- # the URL to link to (in order of priority):
100
- # 1. home_contact_us_url
101
- # 2. contact_us_url
102
- #
103
- # Example routes.rb:
104
- #
105
- # ActionController::Routing::Routes.draw do |map|
106
- # map.with_options(:controller => 'home') do |home|
107
- # home.home '', :action => 'index'
108
- # home.home_search 'search', :action => 'search'
109
- # end
110
- #
111
- # map.with_options(:controller => 'about_us') do |about_us|
112
- # about_us.about_us 'about_us', :action => 'index'
113
- # end
114
- # end
115
- #
116
- # Example menu bar:
117
- #
118
- # menu_bar :home do |home|
119
- # home.menu :about_us # => Links to about_us_url
120
- # home.menu :search # => Links to home_search_url
121
- # end
122
- #
123
- # == URLs with url_for
124
- #
125
- # If neither of these named routes are being used, the url will be based
126
- # on the options passed into the menu. The url_options takes the same
127
- # values as +url_for+. By default, the name of the controller will be
128
- # guessed in the following order:
129
- # 1. The id of the menu ('contact_us' => ContactUsController)
130
- # 2. The controller of the parent menu/menu bar
131
- # 3. The request controller
132
- #
133
- # To override the default controller being linked to, you can explicitly
134
- # define it like so:
135
- # menu :contact, 'Contact Us', :controller => 'about_us'
136
- #
137
- # Examples:
138
- #
139
- # menu :home do |home|
140
- # home.menu :about, 'About Us', :action => 'about_us' # => Links to {:controller => 'home', :action => 'about_us'}
141
- # home.menu :who_we_are # => Links to {:controller => 'home', :action => 'who_we_are'}
142
- # home.menu :contact_us, :controller => 'contact', :action => 'index' # => Links to {:controller => 'contact', :action => 'index'}
143
- # home.menu :search # => Links to {:controller => 'search'}
144
- # end
145
- #
146
- # You can also link to an explicit URL like so:
147
- #
148
- # home.menu :search, 'http://www.google.com'
149
- #
150
- # == Turning off links
151
- #
152
- # If you don't want a menu to link to a URL, you can turn off linking like
153
- # so:
154
- #
155
- # home.menu :contact_us, {}, :link => false
156
- #
157
- # == Defining content and html attributes
158
- #
159
- # By default, the content within a menu will be set as a humanized
160
- # version of the menu's id. Examples of menus which customize the
161
- # content and/or html attributes are below:
162
- #
163
- # home.menu :contact # => <li id="contact"><a href="/contact">Contact</a></li>
164
- # home.menu :contact, 'Contact Us' # => <li id="contact"><a href="/contact">Contact Us</a></li>
165
- # home.menu :contact, {}, :class => 'pretty' # => <li id="contact" class="pretty"><a href="/contact">Contact</a></li>
166
- # home.menu :contact, 'Get in touch!', {}, :class => 'pretty' # => <li id="contact" class="pretty"><a href="/contact">Contact Us</a></li>
167
- #
168
- # == Sub-menus
169
- #
170
- # Menus can also have their own sub-menus by passing in a block. You can
171
- # create sub-menus in the same manner that the main menus are created.
172
- # For example,
173
- #
174
- # home.menu :about do |about|
175
- # about.menu :who_we_are
176
- # about.menu :contact_us
177
- # end
178
- def menu(id, content = nil, url_options = {}, html_options = {}, &block)
179
- menu = Menu.new(self, id, content, url_options, html_options, &block)
180
- @menus << menu
181
-
182
- menu
189
+ content_tag(tag_name, content, html_options)
190
+ end
191
+
192
+ private
193
+ # Unordered list
194
+ def tag_name
195
+ 'ul'
183
196
  end
184
197
 
185
- # Builds the actual html of the menu bar
186
- def html
187
- html_options = @html_options.dup
188
- html_options[:class] = "#{html_options[:class]} #{selected_class}".strip if selected?
189
-
190
- content_tag(tag_name, content, html_options)
198
+ # Generate the html for the menu bar
199
+ def content
200
+ @menus.inject('') {|html, menu| html << menu.html(@menus.last == menu)}
191
201
  end
192
-
193
- private
194
- # Unordered list
195
- def tag_name
196
- 'ul'
197
- end
198
-
199
- # Generate the html for the menu bar
200
- def content
201
- @menus.inject('') {|html, menu| html << menu.html(@menus.last == menu)}
202
- end
203
- end
204
202
  end
205
203
  end
data/lib/menu_helper.rb CHANGED
@@ -2,113 +2,111 @@ require 'menu_helper/html_element'
2
2
  require 'menu_helper/menu_bar'
3
3
  require 'menu_helper/menu'
4
4
 
5
- module PluginAWeek #:nodoc:
6
- # Provides a builder for generating html menu bars. The structure of the
7
- # menus/menu bars is based on lists and should be styled using css.
8
- module MenuHelper
9
- # Creates a new first-level menu bar. This takes the configuration options
10
- # for the menu bar, followed by html options. Both of these parameters are
11
- # optional.
12
- #
13
- # Configuration options:
14
- # * +auto_set_ids+ - Whether or not to automatically add ids to each menu/menu bar. Default is true.
15
- # * +attach_active_submenus+ - Whether any active sub-menu bar should be rendered as part of its parent menu. Default is true.
16
- # * +content_for+ - The base block name to use when detaching active submenus. Default is "menu_bar". For example, this will render sub-menu bars to menu_bar_level_2
17
- #
18
- # == Examples
19
- #
20
- # menu_bar({}, :id => 'nav', :class => 'pretty') do |main|
21
- # main.menu :home
22
- # main.menu :about_us do |about_us|
23
- # about_us.menu :who_we_are
24
- # about_us.menu :what_we_do
25
- # about_us.menu :where_we_are
26
- # about_us.menu :contact, 'Contact', 'mailto:contact@us.com'
27
- # end
28
- # end
29
- #
30
- # ...generates the following html if +about_us+ is selected...
31
- #
32
- # <ul id="nav" class="pretty menubar menubar-1">
33
- # <li id="nav-home"><a href="/"><span>Home</span></a></li>
34
- # <li id="nav-about_us" class="menubar-selected"><a href="/about_us"><span>About Us</span></a>
35
- # <ul class="menubar menubar-2" class="menubar-selected">
36
- # <li id="nav-about_us-who_we_are"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
37
- # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
38
- # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
39
- # </ul>
40
- # </li>
41
- # </ul>
42
- #
43
- # Submenus can be detached from the original parent menu for greater control
44
- # over layout. For example,
45
- #
46
- # menu_bar({:attach_active_submenus => false}, :id => 'nav') do |main|
47
- # main.menu :home
48
- # main.menu :about_us do |about_us|
49
- # about_us.menu :who_we_are
50
- # about_us.menu :what_we_do
51
- # about_us.menu :where_we_are
52
- # end
53
- # end
54
- #
55
- # <div id="subnav">
56
- # <%= yield :menu_bar_level_2 %>
57
- # </div>
58
- #
59
- # ...generates the following html if +about_us+ is selected...
60
- #
61
- # <ul id="nav" class="menubar menubar-1">
62
- # <li id="nav-home"><a href="/"><span>Home</span></a></li>
63
- # <li id="nav-about_us" class="menubar-selected"><a href="/about_us"><span>About Us</span></a></li>
64
- # </ul>
65
- #
66
- # <div id="subnav">
67
- # <ul class="menubar menubar-2 menubar-selected">
68
- # <li id="nav-about_us-who_we_are"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
69
- # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
70
- # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
71
- # </ul>
72
- # </div>
73
- #
74
- # == Menu Selection
75
- #
76
- # The currently selected menu is based on the current page that is displayed
77
- # to the user. If the url that the menu links to is the same as the
78
- # current page, then that menu will be selected. This menu uses
79
- # ActionView::Helpers::UrlHelper#current_page? to determine whether or not
80
- # it is the currently selected menu.
81
- #
82
- # If the menu that is selected is nested within another menu, then those
83
- # menus will be selected as well.
84
- #
85
- # A "selected" menu/menu bar is indicated by an additional css class that is
86
- # added to the element.
87
- #
88
- # For example, if a sub-menu like +who_we_are+ is selected, the html
89
- # generated from the above full example would look like so:
90
- #
91
- # <ul id="nav" class="pretty menubar menubar-1">
92
- # <li id="nav-home"><a href="/"><span>Home</span></a></li>
93
- # <li id="nav-about_us" class="menubar-selected"><span>About Us</span>
94
- # <ul class="menubar menubar-2 menubar-selected">
95
- # <li id="nav-about_us-who_we_are" class="menubar-selected"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
96
- # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
97
- # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
98
- # </ul>
99
- # </li>
100
- # </ul>
101
- #
102
- # == Menu Creation
103
- #
104
- # For more information about how menus are created, see the documentation
105
- # for PluginAWeek::MenuHelper::MenuBar#menu.
106
- def menu_bar(options = {}, html_options = {}, &block)
107
- MenuBar.new(@controller, options, html_options, &block).html
108
- end
5
+ # Provides a builder for generating html menu bars. The structure of the
6
+ # menus/menu bars is based on lists and should be styled using css.
7
+ module MenuHelper
8
+ # Creates a new first-level menu bar. This takes the configuration options
9
+ # for the menu bar, followed by html options. Both of these parameters are
10
+ # optional.
11
+ #
12
+ # Configuration options:
13
+ # * +auto_set_ids+ - Whether or not to automatically add ids to each menu/menu bar. Default is true.
14
+ # * +attach_active_submenus+ - Whether any active sub-menu bar should be rendered as part of its parent menu. Default is true.
15
+ # * +content_for+ - The base block name to use when detaching active submenus. Default is "menu_bar". For example, this will render sub-menu bars to menu_bar_level_2
16
+ #
17
+ # == Examples
18
+ #
19
+ # menu_bar({}, :id => 'nav', :class => 'pretty') do |main|
20
+ # main.menu :home
21
+ # main.menu :about_us do |about_us|
22
+ # about_us.menu :who_we_are
23
+ # about_us.menu :what_we_do
24
+ # about_us.menu :where_we_are
25
+ # about_us.menu :contact, 'Contact', 'mailto:contact@us.com'
26
+ # end
27
+ # end
28
+ #
29
+ # ...generates the following html if +about_us+ is selected...
30
+ #
31
+ # <ul id="nav" class="pretty menubar menubar-1">
32
+ # <li id="nav-home"><a href="/"><span>Home</span></a></li>
33
+ # <li id="nav-about_us" class="menubar-selected"><a href="/about_us"><span>About Us</span></a>
34
+ # <ul class="menubar menubar-2" class="menubar-selected">
35
+ # <li id="nav-about_us-who_we_are"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
36
+ # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
37
+ # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
38
+ # </ul>
39
+ # </li>
40
+ # </ul>
41
+ #
42
+ # Submenus can be detached from the original parent menu for greater control
43
+ # over layout. For example,
44
+ #
45
+ # menu_bar({:attach_active_submenus => false}, :id => 'nav') do |main|
46
+ # main.menu :home
47
+ # main.menu :about_us do |about_us|
48
+ # about_us.menu :who_we_are
49
+ # about_us.menu :what_we_do
50
+ # about_us.menu :where_we_are
51
+ # end
52
+ # end
53
+ #
54
+ # <div id="subnav">
55
+ # <%= yield :menu_bar_level_2 %>
56
+ # </div>
57
+ #
58
+ # ...generates the following html if +about_us+ is selected...
59
+ #
60
+ # <ul id="nav" class="menubar menubar-1">
61
+ # <li id="nav-home"><a href="/"><span>Home</span></a></li>
62
+ # <li id="nav-about_us" class="menubar-selected"><a href="/about_us"><span>About Us</span></a></li>
63
+ # </ul>
64
+ #
65
+ # <div id="subnav">
66
+ # <ul class="menubar menubar-2 menubar-selected">
67
+ # <li id="nav-about_us-who_we_are"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
68
+ # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
69
+ # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
70
+ # </ul>
71
+ # </div>
72
+ #
73
+ # == Menu Selection
74
+ #
75
+ # The currently selected menu is based on the current page that is displayed
76
+ # to the user. If the url that the menu links to is the same as the
77
+ # current page, then that menu will be selected. This menu uses
78
+ # ActionView::Helpers::UrlHelper#current_page? to determine whether or not
79
+ # it is the currently selected menu.
80
+ #
81
+ # If the menu that is selected is nested within another menu, then those
82
+ # menus will be selected as well.
83
+ #
84
+ # A "selected" menu/menu bar is indicated by an additional css class that is
85
+ # added to the element.
86
+ #
87
+ # For example, if a sub-menu like +who_we_are+ is selected, the html
88
+ # generated from the above full example would look like so:
89
+ #
90
+ # <ul id="nav" class="pretty menubar menubar-1">
91
+ # <li id="nav-home"><a href="/"><span>Home</span></a></li>
92
+ # <li id="nav-about_us" class="menubar-selected"><span>About Us</span>
93
+ # <ul class="menubar menubar-2 menubar-selected">
94
+ # <li id="nav-about_us-who_we_are" class="menubar-selected"><a href="/about_us/who_we_are"><span>Who We Are</span></a></li>
95
+ # <li id="nav-about_us-what_we_do"><a href="/about_us/what_we_do"><span>What We Do</span></a></li>
96
+ # <li id="nav-about_us-contact"><a href="mailto:contact@us.com"><span>Contact</span></a></li>
97
+ # </ul>
98
+ # </li>
99
+ # </ul>
100
+ #
101
+ # == Menu Creation
102
+ #
103
+ # For more information about how menus are created, see the documentation
104
+ # for MenuHelper::MenuBar#menu.
105
+ def menu_bar(options = {}, html_options = {}, &block)
106
+ MenuBar.new(@controller, options, html_options, &block).html
109
107
  end
110
108
  end
111
109
 
112
110
  ActionController::Base.class_eval do
113
- helper PluginAWeek::MenuHelper
111
+ helper MenuHelper
114
112
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
 
3
3
  class MenuHelperTest < ActionView::TestCase
4
- tests PluginAWeek::MenuHelper
4
+ tests MenuHelper
5
5
 
6
6
  def test_should_build_menu_bar
7
7
  menu_bar_html = menu_bar({}, :class => 'pretty') do |main|