bootstrap-navbar 1.0.0.pre2 → 1.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e6cb5d7ab4f17cc09849836050063a1759811c1
4
- data.tar.gz: 4f4ed9a21184025348dc77eb803b93a3a18fa1b1
3
+ metadata.gz: c1bf017cd13c884bc254a7d2c1d52f62544fe429
4
+ data.tar.gz: 74035cc23f029cb5fae56f2d1089e03435453357
5
5
  SHA512:
6
- metadata.gz: 589e6877047fdc0dcf224219d9a89ecca22ef1e1b8efdffadedabf918f0e02a4e57778f35bfc9d62b72fb3df35f6e6d5f31085d36011d4189f707348c70cce3a
7
- data.tar.gz: 8def888b261d8445b59bcc2ee7010fd44b9aec41fdc48f6ec1144f75e3c189692cd08f89f474b891b45de7c2795a6da0bff43067a0a263ea9d2a6b3e4ae8a6ac
6
+ metadata.gz: d98ebb16e693c825e5daf3b0b41ac32e8d33e2093d2031be02e40c6945523e0ec49d3632610ca28ec753598f9d38da1d5f02233f10bed157360788437631a5ed
7
+ data.tar.gz: 243b505a37bfca17f9bc5335b4537a661bbd96e59c1affc7006881ba8b2cddc0ee7ea039699706d52f27c7c005042718ef3eb3bd9a6fdde158fc5ac1fbee3880
data/README.md CHANGED
@@ -67,477 +67,11 @@ ActionView::Base.send :include, BootstrapNavbar::Helpers
67
67
 
68
68
  ## Usage
69
69
 
70
- Check out the [Twitter Bootstrap docs](http://twitter.github.io/bootstrap/components.html#navbar) for how a navbar can be constructed. All components and options mentioned there should be supported by this gem, so you don't need to write any HTML by hand. If there is something missing or wrong HTML is generated, please [open an issue](https://github.com/krautcomputing/bootstrap-navbar/issues).
70
+ Since the navbar format changed quite a bit between Bootstrap 2.x and 3.x, generating them using this gem is quite different as well. Check out the Wiki pages for detailed instructions:
71
71
 
72
- Let's assume you have mixed in the helper in your rendering engine and use Haml.
72
+ [Usage with Bootstrap 2.x](https://github.com/krautcomputing/bootstrap-navbar/wiki/Usage-with-Bootstrap-2.x)
73
73
 
74
- ### Full example
75
-
76
- ```ruby
77
- = navbar brand: 'My great app', brand_link: '/home', fixed: :top, responsive: true do
78
- = menu_group class: 'foo', id: 'menu' do
79
- = menu_text 'Pick an option:'
80
- = menu_item "Home", root_path
81
- = menu_item "About Us", about_us_path
82
- = menu_item contact_path do
83
- = image_tag 'contact.jpg'
84
- Contact Us!
85
- = menu_divider
86
- = drop_down "Stuff" do
87
- = drop_down_header 'Great stuff!'
88
- = menu_item "One", one_path
89
- = menu_item "Two", two_path
90
- = menu_item "Three", three_path
91
- - if current_user.admin?
92
- = drop_down_divider
93
- = sub_drop_down 'Admin Stuff' do
94
- = menu_item "Admin Dashboard", admin_path
95
- = menu_item "Users", admin_users_path
96
- = menu_group pull: 'right' do
97
- - if current_user
98
- = menu_item "Log Out", log_out_path
99
- - else
100
- = menu_item "Log In", log_in_path
101
- ```
102
-
103
- ### Methods
104
-
105
- #### navbar
106
-
107
- This method sets up the basic structure of a navbar.
108
-
109
- ```haml
110
- = navbar
111
- ```
112
-
113
- generates:
114
-
115
- ```html
116
- <div class="navbar">
117
- <div class="navbar-inner">
118
- <div class="container">
119
- </div>
120
- </div>
121
- </div>
122
- ```
123
-
124
- The content of the navbar is supplied by the block and the available options:
125
-
126
- ```haml
127
- = navbar do
128
- Yay!
129
- ```
130
-
131
- generates:
132
-
133
- ```html
134
- <div class="navbar">
135
- <div class="navbar-inner">
136
- <div class="container">
137
- Yay!
138
- </div>
139
- </div>
140
- </div>
141
- ```
142
-
143
- Options `brand` and `brand_link` autogenerate the brand link:
144
-
145
- ```haml
146
- = navbar brand: 'My great app', brand_link: '/start'
147
- ```
148
-
149
- generates:
150
-
151
- ```html
152
- <div class="navbar">
153
- <div class="navbar-inner">
154
- <div class="container">
155
- <a href="/start" class="brand">My great app</a>
156
- </div>
157
- </div>
158
- </div>
159
- ```
160
-
161
- If only `brand` is defined, `brand_link` defaults to `/`.
162
-
163
- Option `responsive` generates a responsive navbar:
164
-
165
- ```haml
166
- = navbar responsive: true
167
- ```
168
-
169
- generates:
170
-
171
- ```html
172
- <div class="navbar">
173
- <div class="navbar-inner">
174
- <div class="container">
175
- <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
176
- <span class='icon-bar'></span>
177
- <span class='icon-bar'></span>
178
- <span class='icon-bar'></span>
179
- </a>
180
- <div class="nav-collapse collapse">
181
- </div>
182
- </div>
183
- </div>
184
- </div>
185
- ```
186
-
187
- **Attention: when using the `responsive` option, the brand link should not be added through the `brand_link` method but directly supplied to the `navbar` call.**
188
-
189
- Don't do this:
190
-
191
- ```haml
192
- = navbar responsive: true do
193
- = brand_link 'My great app', '/home'
194
- ```
195
-
196
- Do this:
197
-
198
- ```haml
199
- = navbar responsive: true, brand: 'My great app', brand_link: '/home'
200
- ```
201
-
202
- Otherwise the brand link will be nested incorrectly and will disappear when resizing the window to a smaller size.
203
-
204
- Option `fluid` changes the grid system to be [fluid](http://twitter.github.io/bootstrap/scaffolding.html#fluidGridSystem):
205
-
206
- ```haml
207
- = navbar fluid: true
208
- ```
209
-
210
- generates:
211
-
212
- ```html
213
- <div class="navbar">
214
- <div class="navbar-inner">
215
- <div class="container-fluid">
216
- </div>
217
- </div>
218
- </div>
219
- ```
220
-
221
- #### brand_link
222
-
223
- This method generates a menu divider, to be used in a `navbar`.
224
-
225
- ```haml
226
- = brand_link 'My App', '/home'
227
- ```
228
-
229
- generates:
230
-
231
- ```html
232
- <a href="/home" class="brand">My App</a>
233
- ```
234
-
235
- If the path (`/home` in this case) is not specified, it defaults to `/`.
236
-
237
- #### menu_text
238
-
239
- This method generates some menu text, to be used in a `navbar`.
240
-
241
- ```haml
242
- = menu_text 'Select a option:'
243
- ```
244
-
245
- generates:
246
-
247
- ```html
248
- <p class="navbar-text">
249
- Select a option:
250
- </p>
251
- ```
252
-
253
- A option can be supplied to make the text float to the right or left:
254
-
255
- ```haml
256
- = menu_text 'Select a option:', :right
257
- ```
258
-
259
- generates:
260
-
261
- ```html
262
- <p class="navbar-text pull-right">
263
- Select a option:
264
- </p>
265
- ```
266
-
267
- The content can alternatively be supplied in a block:
268
-
269
- ```haml
270
- = menu_text do
271
- Current country:
272
- = image_text 'flags/en.jpg'
273
- ```
274
-
275
- generates:
276
-
277
- ```html
278
- <p class="navbar-text">
279
- Current country:
280
- <img src="/images/flags/en.jpg">
281
- </p>
282
- ```
283
-
284
- #### menu_group
285
-
286
- This method generates a menu group, to be used in a `navbar`.
287
-
288
- ```haml
289
- = menu_group
290
- ```
291
-
292
- generates:
293
-
294
- ```html
295
- <ul class="nav">
296
- </ul>
297
- ```
298
-
299
- The content of the menu group is supplied by the blocks:
300
-
301
- ```haml
302
- = menu_group do
303
- Yay!
304
- ```
305
-
306
- generates:
307
-
308
- ```html
309
- <ul class="nav">
310
- Yay!
311
- </ul>
312
- ```
313
-
314
- You can add a `pull` option to make the group float to the right or left, and add more classes and other attributes:
315
-
316
- ```haml
317
- = menu_group pull: 'right', class: 'large', id: 'menu'
318
- ```
319
-
320
- generates:
321
-
322
- ```html
323
- <ul class="nav pull-right large" id="menu">
324
- </ul>
325
- ```
326
-
327
- #### menu_item
328
-
329
- This method generates a menu item, to be used in a `menu_group`.
330
-
331
- ```haml
332
- = menu_item 'Home', '/home'
333
- ```
334
-
335
- generates:
336
-
337
- ```html
338
- <li>
339
- <a href="/home">
340
- Home
341
- </a>
342
- </li>
343
- ```
344
-
345
- If the path (`/home` in this case) is not specified, it defaults to `#`.
346
-
347
- You can also use a block (e.g., in case the link name is more than a single word):
348
-
349
- ```haml
350
- = menu_item /home' do
351
- = image_tag 'home.png'
352
- Home
353
- ```
354
-
355
- generates:
356
-
357
- ```html
358
- <li>
359
- <a href="/home">
360
- <img src="/images/home.png">
361
- Home
362
- </a>
363
- </li>
364
- ```
365
-
366
- You can add options that will be passed on to the `li` and `a` elements:
367
-
368
- ```haml
369
- = menu_item 'Home', '/home', { class: 'list-item' }, { id: 'home' }
370
- ```
371
-
372
- generates:
373
-
374
- ```html
375
- <li class="list-item">
376
- <a href="/home" id="home">
377
- Home
378
- </a>
379
- </li>
380
- ```
381
-
382
- If the specified path/URL is the [current url](#set-current_url_method-required), it will be marked as `active`. Note that it doesn't matter if you link to a full URL or just the path, or if `BootstrapNavbar.configuration.current_url_method` returns a full URL or just the path, it will work regardless.
383
-
384
- ```haml
385
- = menu_item 'Home', '/home'
386
- ```
387
-
388
- generates:
389
-
390
- ```html
391
- <!-- If the current path is /home -->
392
-
393
- <li class="active">
394
- <a href="/home">
395
- Home
396
- </a>
397
- </li>
398
- ```
399
-
400
- #### menu_divider
401
-
402
- This method generates a menu divider, to be used in a `menu_group`.
403
-
404
- ```haml
405
- = menu_divider
406
- ```
407
-
408
- generates:
409
-
410
- ```html
411
- <li class="divider-vertical"></li>
412
- ```
413
-
414
- #### drop_down
415
-
416
- This method generates a dropdown, to be used in a `menu_group`.
417
-
418
- ```haml
419
- = drop_down 'Settings'
420
- ```
421
-
422
- generates:
423
-
424
- ```html
425
- <li class="dropdown">
426
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">
427
- Settings <b class="caret"></b>
428
- </a>
429
- <ul class="dropdown-menu">
430
- </ul>
431
- </li>
432
- ```
433
-
434
- The content of the dropdown can be defined in the block using `menu_item`s:
435
-
436
- ```haml
437
- = drop_down 'Settings' do
438
- = menu_item 'Basic', '/settings/basic'
439
- = menu_item 'Advanced', '/settings/advanced'
440
- ```
441
-
442
- generates:
443
-
444
- ```html
445
- <li class="dropdown">
446
- <a href="#" class="dropdown-toggle" data-toggle="dropdown">
447
- Settings <b class="caret"></b>
448
- </a>
449
- <ul class="dropdown-menu">
450
- <li>
451
- <a href="/settings/basic">
452
- Basic
453
- </a>
454
- </li>
455
- <li>
456
- <a href="/settings/advanced">
457
- Advanced
458
- </a>
459
- </li>
460
- </ul>
461
- </li>
462
- ```
463
-
464
- #### sub_drop_down
465
-
466
- This method generates a sub dropdown, to be used in a `drop_down`.
467
-
468
- ```haml
469
- = sub_drop_down 'Admin Settings'
470
- ```
471
-
472
- generates:
473
-
474
- ```html
475
- <li class="dropdown-submenu">
476
- <a href="#">
477
- Admin Settings
478
- </a>
479
- <ul class="dropdown-menu">
480
- </ul>
481
- </li>
482
- ```
483
-
484
- Just like in the `drop_down`, the content of the sub dropdown is defined in the block:
485
-
486
- ```haml
487
- = sub_drop_down 'Admin Settings' do
488
- = menu_item 'Users', '/settings/admin/users'
489
- = menu_item 'Stats', '/settings/admin/stats'
490
- ```
491
-
492
- generates:
493
-
494
- ```html
495
- <li class="dropdown-submenu">
496
- <a href="#">
497
- Admin Settings
498
- </a>
499
- <ul class="dropdown-menu">
500
- <li>
501
- <a href="/settings/admin/users">
502
- Users
503
- </a>
504
- </li>
505
- <li>
506
- <a href="/settings/admin/stats">
507
- Stats
508
- </a>
509
- </li>
510
- </ul>
511
- </li>
512
- ```
513
-
514
- #### drop_down_divider
515
-
516
- This method generates a dropdown divider, to be used in a `drop_down` or `sub_drop_down`.
517
-
518
- ```haml
519
- = drop_down_divider
520
- ```
521
-
522
- generates:
523
-
524
- ```html
525
- <li class="divider"></li>
526
- ```
527
-
528
- #### drop_down_header
529
-
530
- This method generates a dropdown header, to be used in a `drop_down` or `sub_drop_down`.
531
-
532
- ```haml
533
- = drop_down_header 'Important!'
534
- ```
535
-
536
- generates:
537
-
538
- ```html
539
- <li class="nav-header">Important!</li>
540
- ```
74
+ [Usage with Bootstrap 3.x](https://github.com/krautcomputing/bootstrap-navbar/wiki/Usage-with-Bootstrap-3.x)
541
75
 
542
76
  ## Contributing
543
77
 
@@ -1,15 +1,16 @@
1
1
  module BootstrapNavbar::Helpers
2
2
  def self.included(base)
3
- helper_version = BootstrapNavbar.configuration.bootstrap_version.split('.').first
4
- base.send :include, const_get("BootstrapNavbar::Helpers::Bootstrap#{helper_version}")
3
+ helper_version = BootstrapNavbar.configuration.bootstrap_version[0]
4
+ base.send :include, const_get("Bootstrap#{helper_version}")
5
5
  end
6
6
 
7
- def with_preceding_space(attributes)
8
- ' ' << attributes unless [nil, ''].include?(attributes)
9
- end
10
-
11
- def attribute_hash_to_string(hash)
12
- hash.map { |k, v| %(#{k}="#{v}") }.join(' ')
7
+ def attributes_for_tag(hash)
8
+ string = hash.map { |k, v| %(#{k}="#{v}") }.join(' ')
9
+ if string.length > 0
10
+ ' ' << string
11
+ else
12
+ string
13
+ end
13
14
  end
14
15
 
15
16
  def current_url?(url)
@@ -1,26 +1,26 @@
1
1
  module BootstrapNavbar::Helpers::Bootstrap2
2
2
  def navbar(options = {}, &block)
3
- navbar_wrapper options do
4
- navbar_inner_div do
5
- container_div options[:brand], options[:brand_link], options[:responsive], options[:fluid], &block
3
+ wrapper options do
4
+ inner_wrapper do
5
+ container options[:brand], options[:brand_link], options[:responsive], options[:fluid], &block
6
6
  end
7
7
  end
8
8
  end
9
9
 
10
- def menu_group(options = {}, &block)
10
+ def navbar_group(options = {}, &block)
11
11
  css_classes = %w(nav).tap do |css_classes|
12
12
  css_classes << "pull-#{options.delete(:pull)}" if options.has_key?(:pull)
13
13
  css_classes << options.delete(:class) if options.has_key?(:class)
14
14
  end
15
- attributes = attribute_hash_to_string({ class: css_classes.join(' ') }.merge(options))
15
+ attributes = attributes_for_tag({ class: css_classes.join(' ') }.merge(options))
16
16
  prepare_html <<-HTML.chomp!
17
- <ul#{with_preceding_space attributes}>
17
+ <ul#{attributes}>
18
18
  #{capture(&block) if block_given?}
19
19
  </ul>
20
20
  HTML
21
21
  end
22
22
 
23
- def menu_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block)
23
+ def navbar_item(name = nil, path = nil, list_item_options = nil, link_options = nil, &block)
24
24
  name, path, list_item_options, link_options = capture(&block), name, path, list_item_options if block_given?
25
25
  path ||= '#'
26
26
  list_item_options ||= {}
@@ -30,61 +30,61 @@ HTML
30
30
  css_classes << 'active' if current_url?(path)
31
31
  css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
32
32
  end
33
- list_item_attributes = attribute_hash_to_string(
33
+ list_item_attributes = attributes_for_tag(
34
34
  { class: list_item_css_classes.join(' ') }
35
35
  .delete_if { |k, v| v.empty? }
36
36
  .merge(list_item_options)
37
37
  )
38
- link_attributes = attribute_hash_to_string(link_options)
38
+ link_attributes = attributes_for_tag(link_options)
39
39
  prepare_html <<-HTML.chomp!
40
- <li#{with_preceding_space list_item_attributes}>
41
- <a href="#{path}"#{with_preceding_space link_attributes}>
40
+ <li#{list_item_attributes}>
41
+ <a href="#{path}"#{link_attributes}>
42
42
  #{name}
43
43
  </a>
44
44
  </li>
45
45
  HTML
46
46
  end
47
47
 
48
- def drop_down(name, &block)
48
+ def navbar_dropdown(name, &block)
49
49
  prepare_html <<-HTML.chomp!
50
50
  <li class="dropdown">
51
51
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
52
52
  #{name} <b class="caret"></b>
53
53
  </a>
54
- #{drop_down_menu(&block)}
54
+ #{dropdown_menu(&block)}
55
55
  </li>
56
56
  HTML
57
57
  end
58
58
 
59
- def sub_drop_down(name, list_item_options = {}, link_options = {}, &block)
59
+ def navbar_sub_dropdown(name, list_item_options = {}, link_options = {}, &block)
60
60
  list_item_css_classes = %w(dropdown-submenu).tap do |css_classes|
61
61
  css_classes << list_item_options.delete(:class) if list_item_options.has_key?(:class)
62
62
  end
63
- list_item_attributes = attribute_hash_to_string({ class: list_item_css_classes.join(' ') }.merge(list_item_options))
64
- link_attributes = attribute_hash_to_string(link_options)
63
+ list_item_attributes = attributes_for_tag({ class: list_item_css_classes.join(' ') }.merge(list_item_options))
64
+ link_attributes = attributes_for_tag(link_options)
65
65
  prepare_html <<-HTML.chomp!
66
- <li#{with_preceding_space list_item_attributes}>
67
- <a href="#"#{with_preceding_space link_attributes}>
66
+ <li#{list_item_attributes}>
67
+ <a href="#"#{link_attributes}>
68
68
  #{name}
69
69
  </a>
70
- #{drop_down_menu(&block)}
70
+ #{dropdown_menu(&block)}
71
71
  </li>
72
72
  HTML
73
73
  end
74
74
 
75
- def drop_down_divider
75
+ def navbar_dropdown_divider
76
76
  prepare_html %(<li class="divider"></li>)
77
77
  end
78
78
 
79
- def drop_down_header(text)
79
+ def navbar_dropdown_header(text)
80
80
  prepare_html %(<li class="nav-header">#{text}</li>)
81
81
  end
82
82
 
83
- def menu_divider
83
+ def navbar_divider
84
84
  prepare_html %(<li class="divider-vertical"></li>)
85
85
  end
86
86
 
87
- def menu_text(text = nil, pull = nil, &block)
87
+ def navbar_text(text = nil, pull = nil, &block)
88
88
  css_classes = %w(navbar-text).tap do |css_classes|
89
89
  css_classes << "pull-#{pull}" if pull
90
90
  end
@@ -95,13 +95,13 @@ HTML
95
95
  HTML
96
96
  end
97
97
 
98
- def brand_link(name, url = nil)
98
+ def navbar_brand_link(name, url = nil)
99
99
  prepare_html %(<a href="#{url || '/'}" class="brand">#{name}</a>)
100
100
  end
101
101
 
102
102
  private
103
103
 
104
- def navbar_wrapper(options, &block)
104
+ def wrapper(options, &block)
105
105
  position = case
106
106
  when options.has_key?(:static)
107
107
  "static-#{options[:static]}"
@@ -114,16 +114,16 @@ HTML
114
114
  css_classes << 'navbar-inverse' if options[:inverse]
115
115
  end
116
116
  attribute_hash = { class: css_classes.join(' ') }
117
- attributes = attribute_hash_to_string(attribute_hash)
117
+ attributes = attributes_for_tag(attribute_hash)
118
118
 
119
119
  prepare_html <<-HTML.chomp!
120
- <div#{with_preceding_space attributes}>
120
+ <div#{attributes}>
121
121
  #{capture(&block) if block_given?}
122
122
  </div>
123
123
  HTML
124
124
  end
125
125
 
126
- def navbar_inner_div(&block)
126
+ def inner_wrapper(&block)
127
127
  prepare_html <<-HTML.chomp!
128
128
  <div class="navbar-inner">
129
129
  #{capture(&block) if block_given?}
@@ -131,11 +131,11 @@ HTML
131
131
  HTML
132
132
  end
133
133
 
134
- def container_div(brand, brand_link, responsive, fluid, &block)
134
+ def container(brand, brand_link, responsive, fluid, &block)
135
135
  css_class = fluid ? 'container-fluid' : 'container'
136
136
  content = [].tap do |content|
137
137
  content << responsive_button if responsive
138
- content << brand_link(brand, brand_link) if brand || brand_link
138
+ content << navbar_brand_link(brand, brand_link) if brand || brand_link
139
139
  content << if responsive
140
140
  responsive_wrapper(&block)
141
141
  else
@@ -153,9 +153,9 @@ HTML
153
153
  css_classes = %w(nav-collapse).tap do |css_classes|
154
154
  css_classes << 'collapse' if BootstrapNavbar.configuration.bootstrap_version >= '2.2.0'
155
155
  end
156
- attributes = attribute_hash_to_string({ class: css_classes.join(' ') })
156
+ attributes = attributes_for_tag({ class: css_classes.join(' ') })
157
157
  prepare_html <<-HTML.chomp!
158
- <div#{with_preceding_space attributes}>
158
+ <div#{attributes}>
159
159
  #{capture(&block) if block_given?}
160
160
  </div>
161
161
  HTML
@@ -171,7 +171,7 @@ HTML
171
171
  HTML
172
172
  end
173
173
 
174
- def drop_down_menu(&block)
174
+ def dropdown_menu(&block)
175
175
  prepare_html <<-HTML.chomp!
176
176
  <ul class="dropdown-menu">
177
177
  #{capture(&block) if block_given?}
@@ -2,11 +2,11 @@ module BootstrapNavbar::Helpers::Bootstrap3
2
2
  def navbar(options = {}, &block)
3
3
  container = options.has_key?(:container) ? options[:container] : true
4
4
  navbar_content =
5
- navbar_header(options[:brand], options[:brand_link]) <<
6
- navbar_collapsable(&block)
7
- navbar_wrapper options do
5
+ header(options[:brand], options[:brand_link]) <<
6
+ collapsable(&block)
7
+ wrapper options do
8
8
  if container
9
- navbar_container(navbar_content)
9
+ container(navbar_content)
10
10
  else
11
11
  navbar_content
12
12
  end
@@ -17,14 +17,25 @@ module BootstrapNavbar::Helpers::Bootstrap3
17
17
  css_classes = %w(nav navbar-nav).tap do |css_classes|
18
18
  css_classes << "navbar-#{options[:align]}" if options.has_key?(:align)
19
19
  end
20
- attributes = attribute_hash_to_string({ class: css_classes.join(' ') }.merge(options))
20
+ attributes = attributes_for_tag({ class: css_classes.join(' ') }.merge(options))
21
21
  prepare_html <<-HTML.chomp!
22
- <ul#{with_preceding_space attributes}>
22
+ <ul#{attributes}>
23
23
  #{capture(&block) if block_given?}
24
24
  </ul>
25
25
  HTML
26
26
  end
27
27
 
28
+ def navbar_group_item(text, url)
29
+ attributes = {}
30
+ attributes[:class] = 'active' if current_url?(url)
31
+ attributes = attributes_for_tag(attributes)
32
+ prepare_html <<-HTML.chomp!
33
+ <li#{attributes}>
34
+ <a href="#{url}">#{text}</a>
35
+ </li>
36
+ HTML
37
+ end
38
+
28
39
  def navbar_dropdown(text, &block)
29
40
  prepare_html <<-HTML.chomp!
30
41
  <li class="dropdown">
@@ -36,25 +47,14 @@ HTML
36
47
  HTML
37
48
  end
38
49
 
39
- def navbar_group_item(text, url)
40
- attributes = {}
41
- attributes[:class] = 'active' if current_url?(url)
42
- attributes = attribute_hash_to_string(attributes)
43
- prepare_html <<-HTML.chomp!
44
- <li#{with_preceding_space attributes}>
45
- <a href="#{url}">#{text}</a>
46
- </li>
47
- HTML
48
- end
49
-
50
50
  def navbar_form(options = {}, &block)
51
51
  css_classes = %w(navbar-form).tap do |css_classes|
52
52
  css_classes << "navbar-#{options[:align]}" if options.has_key?(:align)
53
53
  end
54
54
  attribute_hash = { class: css_classes.join(' '), role: 'form' }
55
- attributes = attribute_hash_to_string(attribute_hash)
55
+ attributes = attributes_for_tag(attribute_hash)
56
56
  prepare_html <<-HTML.chomp!
57
- <form#{with_preceding_space attributes}>
57
+ <form#{attributes}>
58
58
  #{capture(&block) if block_given?}
59
59
  </form>
60
60
  HTML
@@ -79,15 +79,15 @@ HTML
79
79
  css_classes << options[:class] if options.has_key?(:class)
80
80
  end
81
81
  attribute_hash = { class: css_classes.join(' '), type: 'button' }
82
- attributes = attribute_hash_to_string(attribute_hash)
82
+ attributes = attributes_for_tag(attribute_hash)
83
83
  prepare_html <<-HTML.chomp!
84
- <button#{with_preceding_space attributes}>#{text}</button>
84
+ <button#{attributes}>#{text}</button>
85
85
  HTML
86
86
  end
87
87
 
88
88
  private
89
89
 
90
- def navbar_container(content)
90
+ def container(content)
91
91
  prepare_html <<-HTML.chomp!
92
92
  <div class="container">
93
93
  #{content}
@@ -95,7 +95,7 @@ HTML
95
95
  HTML
96
96
  end
97
97
 
98
- def navbar_header(brand, brand_link)
98
+ def header(brand, brand_link)
99
99
  prepare_html <<-HTML.chomp!
100
100
  <div class="navbar-header">
101
101
  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable">
@@ -109,7 +109,7 @@ HTML
109
109
  HTML
110
110
  end
111
111
 
112
- def navbar_collapsable(&block)
112
+ def collapsable(&block)
113
113
  prepare_html <<-HTML.chomp!
114
114
  <div class="collapse navbar-collapse" id="navbar-collapsable">
115
115
  #{capture(&block) if block_given?}
@@ -121,7 +121,7 @@ HTML
121
121
  prepare_html %(<a href="#{url || '/'}" class="navbar-brand">#{name}</a>)
122
122
  end
123
123
 
124
- def navbar_wrapper(options, &block)
124
+ def wrapper(options, &block)
125
125
  style = options[:inverse] ? 'inverse' : 'default'
126
126
  css_classes = %w(navbar).tap do |css_classes|
127
127
  css_classes << "navbar-fixed-#{options[:fixed]}" if options.has_key?(:fixed)
@@ -130,9 +130,9 @@ HTML
130
130
  css_classes << "navbar-#{style}"
131
131
  end
132
132
  attribute_hash = { class: css_classes.join(' '), role: 'navigation' }
133
- attributes = attribute_hash_to_string(attribute_hash)
133
+ attributes = attributes_for_tag(attribute_hash)
134
134
  prepare_html <<-HTML.chomp!
135
- <nav#{with_preceding_space attributes}>
135
+ <nav#{attributes}>
136
136
  #{capture(&block) if block_given?}
137
137
  </nav>
138
138
  HTML
@@ -1,3 +1,3 @@
1
1
  module BootstrapNavbar
2
- VERSION = '1.0.0.pre2'
2
+ VERSION = '1.0.0.pre3'
3
3
  end
@@ -6,7 +6,7 @@ shared_examples 'active menu item' do
6
6
  paths_and_urls.each do |current_path_or_url|
7
7
  paths_and_urls.each do |menu_path_or_url|
8
8
  BootstrapNavbar.configuration.current_url_method = "'#{current_path_or_url}'"
9
- expect(renderer.menu_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' })
9
+ expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' })
10
10
  end
11
11
  end
12
12
  end
@@ -109,12 +109,12 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
109
109
  end
110
110
  end
111
111
 
112
- describe '#menu_group' do
112
+ describe '#navbar_group' do
113
113
  context 'without parameters' do
114
114
  it 'generates the correct HTML' do
115
115
  with_all_2_dot_x_versions do
116
- expect(renderer.menu_group).to have_tag(:ul, with: { class: 'nav' })
117
- expect(renderer.menu_group { 'foo' }).to have_tag(:ul, with: { class: 'nav' }, text: /foo/)
116
+ expect(renderer.navbar_group).to have_tag(:ul, with: { class: 'nav' })
117
+ expect(renderer.navbar_group { 'foo' }).to have_tag(:ul, with: { class: 'nav' }, text: /foo/)
118
118
  end
119
119
  end
120
120
  end
@@ -122,7 +122,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
122
122
  context 'with "pull" parameter' do
123
123
  it 'generates the correct HTML' do
124
124
  with_all_2_dot_x_versions do
125
- expect(renderer.menu_group(pull: 'right')).to have_tag(:ul, with: { class: 'nav pull-right' })
125
+ expect(renderer.navbar_group(pull: 'right')).to have_tag(:ul, with: { class: 'nav pull-right' })
126
126
  end
127
127
  end
128
128
  end
@@ -130,7 +130,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
130
130
  context 'with "class" parameter' do
131
131
  it 'generates the correct HTML' do
132
132
  with_all_2_dot_x_versions do
133
- expect(renderer.menu_group(class: 'foo')).to have_tag(:ul, with: { class: 'nav foo' })
133
+ expect(renderer.navbar_group(class: 'foo')).to have_tag(:ul, with: { class: 'nav foo' })
134
134
  end
135
135
  end
136
136
  end
@@ -138,7 +138,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
138
138
  context 'with random parameters' do
139
139
  it 'generates the correct HTML' do
140
140
  with_all_2_dot_x_versions do
141
- expect(renderer.menu_group(:'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
141
+ expect(renderer.navbar_group(:'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav', :'data-foo' => 'bar' })
142
142
  end
143
143
  end
144
144
  end
@@ -146,13 +146,13 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
146
146
  context 'with many parameters' do
147
147
  it 'generates the correct HTML' do
148
148
  with_all_2_dot_x_versions do
149
- expect(renderer.menu_group(pull: 'right', class: 'foo', :'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
149
+ expect(renderer.navbar_group(pull: 'right', class: 'foo', :'data-foo' => 'bar')).to have_tag(:ul, with: { class: 'nav foo pull-right', :'data-foo' => 'bar' })
150
150
  end
151
151
  end
152
152
  end
153
153
  end
154
154
 
155
- describe '#menu_item' do
155
+ describe '#navbar_item' do
156
156
  context 'with current URL or path' do
157
157
  # With root URL or path
158
158
  it_behaves_like 'active menu item' do
@@ -202,7 +202,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
202
202
  it 'generates the correct HTML' do
203
203
  with_all_2_dot_x_versions do
204
204
  BootstrapNavbar.configuration.current_url_method = '"/"'
205
- expect(renderer.menu_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'active bar', id: 'baz' })
205
+ expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'active bar', id: 'baz' })
206
206
  end
207
207
  end
208
208
  end
@@ -211,7 +211,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
211
211
  it 'generates the correct HTML' do
212
212
  with_all_2_dot_x_versions do
213
213
  BootstrapNavbar.configuration.current_url_method = '"/"'
214
- expect(renderer.menu_item('foo', '/', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active' }) do
214
+ expect(renderer.navbar_item('foo', '/', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active' }) do
215
215
  with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
216
216
  end
217
217
  end
@@ -222,7 +222,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
222
222
  it 'generates the correct HTML' do
223
223
  with_all_2_dot_x_versions do
224
224
  BootstrapNavbar.configuration.current_url_method = '"/"'
225
- expect(renderer.menu_item('foo', '/', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active bar', id: 'baz' }) do
225
+ expect(renderer.navbar_item('foo', '/', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'active bar', id: 'baz' }) do
226
226
  with_tag :a, with: { href: '/', class: 'pelle', id: 'fant' }, text: /foo/
227
227
  end
228
228
  end
@@ -234,17 +234,17 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
234
234
  it 'generates the correct HTML' do
235
235
  with_all_2_dot_x_versions do
236
236
  BootstrapNavbar.configuration.current_url_method = '"/foo"'
237
- expect(renderer.menu_item('foo')).to have_tag(:li, without: { class: 'active' }) do
237
+ expect(renderer.navbar_item('foo')).to have_tag(:li, without: { class: 'active' }) do
238
238
  with_tag :a, with: { href: '#' }, text: /foo/
239
239
  end
240
- expect(renderer.menu_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
240
+ expect(renderer.navbar_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
241
241
  with_tag :a, with: { href: '/' }, text: /foo/
242
242
  end
243
- expect(renderer.menu_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
243
+ expect(renderer.navbar_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
244
244
  with_tag :a, with: { href: '/bar' }, text: /foo/
245
245
  end
246
246
  BootstrapNavbar.configuration.current_url_method = '"/"'
247
- expect(renderer.menu_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
247
+ expect(renderer.navbar_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
248
248
  with_tag :a, with: { href: '/foo' }, text: /foo/
249
249
  end
250
250
  end
@@ -254,7 +254,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
254
254
  it 'generates the correct HTML' do
255
255
  with_all_2_dot_x_versions do
256
256
  BootstrapNavbar.configuration.current_url_method = '"/foo"'
257
- expect(renderer.menu_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, without: { class: 'active' }, with: { class: 'bar', id: 'baz' })
257
+ expect(renderer.navbar_item('foo', '/', class: 'bar', id: 'baz')).to have_tag(:li, without: { class: 'active' }, with: { class: 'bar', id: 'baz' })
258
258
  end
259
259
  end
260
260
  end
@@ -263,7 +263,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
263
263
  context 'with a block' do
264
264
  it 'generates the correct HTML' do
265
265
  with_all_2_dot_x_versions do
266
- expect(renderer.menu_item { 'bar' }).to have_tag(:li) do
266
+ expect(renderer.navbar_item { 'bar' }).to have_tag(:li) do
267
267
  with_tag :a, with: { href: '#' }, text: /bar/
268
268
  end
269
269
  end
@@ -272,7 +272,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
272
272
  context 'with list item options' do
273
273
  it 'generates the correct HTML' do
274
274
  with_all_2_dot_x_versions do
275
- expect(renderer.menu_item('/foo', class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li, with: { class: 'pelle', id: 'fant' }) do
275
+ expect(renderer.navbar_item('/foo', class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li, with: { class: 'pelle', id: 'fant' }) do
276
276
  with_tag :a, with: { href: '/foo' }, text: /bar/
277
277
  end
278
278
  end
@@ -282,7 +282,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
282
282
  context 'with link options' do
283
283
  it 'generates the correct HTML' do
284
284
  with_all_2_dot_x_versions do
285
- expect(renderer.menu_item('/foo', {}, class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li) do
285
+ expect(renderer.navbar_item('/foo', {}, class: 'pelle', id: 'fant') { 'bar' }).to have_tag(:li) do
286
286
  with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /bar/
287
287
  end
288
288
  end
@@ -292,7 +292,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
292
292
  context 'with list item options and link options' do
293
293
  it 'generates the correct HTML' do
294
294
  with_all_2_dot_x_versions do
295
- expect(renderer.menu_item('/foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant') { 'shnoo' }).to have_tag(:li, with: { class: 'bar', id: 'baz' }) do
295
+ expect(renderer.navbar_item('/foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant') { 'shnoo' }).to have_tag(:li, with: { class: 'bar', id: 'baz' }) do
296
296
  with_tag :a, with: { href: '/foo', class: 'pelle', id: 'fant' }, text: /shnoo/
297
297
  end
298
298
  end
@@ -301,46 +301,46 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
301
301
  end
302
302
  end
303
303
 
304
- context 'drop downs' do
305
- def with_drop_down_menu(content = nil)
304
+ context 'dropdowns' do
305
+ def with_dropdown_menu(content = nil)
306
306
  options = { with: { class: 'dropdown-menu' } }
307
307
  options[:content] = content unless content.nil?
308
308
  with_tag :ul, options
309
309
  end
310
310
 
311
- describe '#drop_down' do
311
+ describe '#navbar_dropdown' do
312
312
  it 'generates the correct HTML' do
313
313
  with_all_2_dot_x_versions do
314
- expect(renderer.drop_down('foo')).to have_tag(:li, with: { class: 'dropdown' }) do
314
+ expect(renderer.navbar_dropdown('foo')).to have_tag(:li, with: { class: 'dropdown' }) do
315
315
  with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
316
316
  with_text /foo/
317
317
  with_tag :b, with: { class: 'caret' }
318
318
  end
319
- with_drop_down_menu
319
+ with_dropdown_menu
320
320
  end
321
321
 
322
- expect(renderer.drop_down('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown' }) do
322
+ expect(renderer.navbar_dropdown('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown' }) do
323
323
  with_tag :a, with: { href: '#', class: 'dropdown-toggle', :'data-toggle' => 'dropdown' } do
324
324
  with_text /foo/
325
325
  with_tag :b, with: { class: 'caret' }
326
326
  end
327
- with_drop_down_menu('bar')
327
+ with_dropdown_menu('bar')
328
328
  end
329
329
  end
330
330
  end
331
331
  end
332
332
 
333
- describe '#sub_drop_down' do
333
+ describe '#navbar_sub_dropdown' do
334
334
  it 'generates the correct HTML' do
335
335
  with_all_2_dot_x_versions do
336
- expect(renderer.sub_drop_down('foo')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
336
+ expect(renderer.navbar_sub_dropdown('foo')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
337
337
  with_tag :a, with: { href: '#' }, text: /foo/
338
- with_drop_down_menu
338
+ with_dropdown_menu
339
339
  end
340
340
 
341
- expect(renderer.sub_drop_down('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
341
+ expect(renderer.navbar_sub_dropdown('foo') { 'bar' }).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
342
342
  with_tag :a, with: { href: '#' }, text: /foo/
343
- with_drop_down_menu('bar')
343
+ with_dropdown_menu('bar')
344
344
  end
345
345
  end
346
346
  end
@@ -348,7 +348,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
348
348
  context 'with list item options' do
349
349
  it 'generates the correct HTML' do
350
350
  with_all_2_dot_x_versions do
351
- expect(renderer.sub_drop_down('foo', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
351
+ expect(renderer.navbar_sub_dropdown('foo', class: 'bar', id: 'baz')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
352
352
  with_tag :a, with: { href: '#' }, text: /foo/
353
353
  end
354
354
  end
@@ -358,7 +358,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
358
358
  context 'with link options' do
359
359
  it 'generates the correct HTML' do
360
360
  with_all_2_dot_x_versions do
361
- expect(renderer.sub_drop_down('foo', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
361
+ expect(renderer.navbar_sub_dropdown('foo', {}, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu' }) do
362
362
  with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
363
363
  end
364
364
  end
@@ -368,7 +368,7 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
368
368
  context 'with list item options and link options' do
369
369
  it 'generates the correct HTML' do
370
370
  with_all_2_dot_x_versions do
371
- expect(renderer.sub_drop_down('foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
371
+ expect(renderer.navbar_sub_dropdown('foo', { class: 'bar', id: 'baz' }, class: 'pelle', id: 'fant')).to have_tag(:li, with: { class: 'dropdown-submenu bar', id: 'baz' }) do
372
372
  with_tag :a, with: { href: '#', class: 'pelle', id: 'fant' }, text: /foo/
373
373
  end
374
374
  end
@@ -377,46 +377,46 @@ describe BootstrapNavbar::Helpers::Bootstrap2 do
377
377
  end
378
378
  end
379
379
 
380
- describe '#drop_down_divider' do
380
+ describe '#navbar_dropdown_divider' do
381
381
  it 'generates the correct HTML' do
382
382
  with_all_2_dot_x_versions do
383
- expect(renderer.drop_down_divider).to have_tag(:li, with: { class: 'divider' }, text: '')
383
+ expect(renderer.navbar_dropdown_divider).to have_tag(:li, with: { class: 'divider' }, text: '')
384
384
  end
385
385
  end
386
386
  end
387
387
 
388
- describe '#drop_down_header' do
388
+ describe '#navbar_dropdown_header' do
389
389
  it 'generates the correct HTML' do
390
390
  with_all_2_dot_x_versions do
391
- expect(renderer.drop_down_header('foo')).to have_tag(:li, with: { class: 'nav-header' }, text: /foo/)
391
+ expect(renderer.navbar_dropdown_header('foo')).to have_tag(:li, with: { class: 'nav-header' }, text: /foo/)
392
392
  end
393
393
  end
394
394
  end
395
395
 
396
- describe '#menu_divider' do
396
+ describe '#navbar_divider' do
397
397
  it 'generates the correct HTML' do
398
398
  with_all_2_dot_x_versions do
399
- expect(renderer.menu_divider).to have_tag(:li, with: { class: 'divider-vertical' }, text: '')
399
+ expect(renderer.navbar_divider).to have_tag(:li, with: { class: 'divider-vertical' }, text: '')
400
400
  end
401
401
  end
402
402
  end
403
403
 
404
- describe '#menu_text' do
404
+ describe '#navbar_text' do
405
405
  it 'generates the correct HTML' do
406
406
  with_all_2_dot_x_versions do
407
- expect(renderer.menu_text('foo')).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
408
- expect(renderer.menu_text { 'foo' }).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
409
- expect(renderer.menu_text('foo', 'right')).to have_tag(:p, with: { class: 'navbar-text pull-right' }, text: /foo/)
410
- expect(renderer.menu_text(nil, 'left') { 'foo' }).to have_tag(:p, with: { class: 'navbar-text pull-left' }, text: /foo/)
407
+ expect(renderer.navbar_text('foo')).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
408
+ expect(renderer.navbar_text { 'foo' }).to have_tag(:p, with: { class: 'navbar-text' }, text: /foo/)
409
+ expect(renderer.navbar_text('foo', 'right')).to have_tag(:p, with: { class: 'navbar-text pull-right' }, text: /foo/)
410
+ expect(renderer.navbar_text(nil, 'left') { 'foo' }).to have_tag(:p, with: { class: 'navbar-text pull-left' }, text: /foo/)
411
411
  end
412
412
  end
413
413
  end
414
414
 
415
- describe '#brand_link' do
415
+ describe '#navbar_brand_link' do
416
416
  it 'generates the correct HTML' do
417
417
  with_all_2_dot_x_versions do
418
- expect(renderer.brand_link('foo')).to have_tag(:a, with: { class: 'brand', href: '/' }, text: /foo/)
419
- expect(renderer.brand_link('foo', '/foo')).to have_tag(:a, with: { class: 'brand', href: '/foo' }, text: /foo/)
418
+ expect(renderer.navbar_brand_link('foo')).to have_tag(:a, with: { class: 'brand', href: '/' }, text: /foo/)
419
+ expect(renderer.navbar_brand_link('foo', '/foo')).to have_tag(:a, with: { class: 'brand', href: '/foo' }, text: /foo/)
420
420
  end
421
421
  end
422
422
  end
@@ -6,7 +6,7 @@ shared_examples 'active navbar link' do
6
6
  paths_and_urls.each do |current_path_or_url|
7
7
  paths_and_urls.each do |menu_path_or_url|
8
8
  BootstrapNavbar.configuration.current_url_method = "'#{current_path_or_url}'"
9
- expect(renderer.navbar_group_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' }) do
9
+ expect(renderer.navbar_item('foo', menu_path_or_url)).to have_tag(:li, with: { class: 'active' }) do
10
10
  with_tag :a, with: { href: menu_path_or_url }, text: /foo/
11
11
  end
12
12
  end
@@ -131,7 +131,7 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
131
131
  end
132
132
  end
133
133
 
134
- describe '#navbar_group_item' do
134
+ describe '#navbar_item' do
135
135
  context 'with current URL or path' do
136
136
  # With root URL or path
137
137
  it_behaves_like 'active navbar link' do
@@ -182,14 +182,14 @@ describe BootstrapNavbar::Helpers::Bootstrap3 do
182
182
  it 'generates the correct HTML' do
183
183
  with_all_3_dot_x_versions do
184
184
  BootstrapNavbar.configuration.current_url_method = '"/foo"'
185
- expect(renderer.navbar_group_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
185
+ expect(renderer.navbar_item('foo', '/')).to have_tag(:li, without: { class: 'active' }) do
186
186
  with_tag :a, with: { href: '/' }, text: /foo/
187
187
  end
188
- expect(renderer.navbar_group_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
188
+ expect(renderer.navbar_item('foo', '/bar')).to have_tag(:li, without: { class: 'active' }) do
189
189
  with_tag :a, with: { href: '/bar' }, text: /foo/
190
190
  end
191
191
  BootstrapNavbar.configuration.current_url_method = '"/"'
192
- expect(renderer.navbar_group_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
192
+ expect(renderer.navbar_item('foo', '/foo')).to have_tag(:li, without: { class: 'active' }) do
193
193
  with_tag :a, with: { href: '/foo' }, text: /foo/
194
194
  end
195
195
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-navbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre2
4
+ version: 1.0.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel Meurer
@@ -114,7 +114,6 @@ files:
114
114
  - lib/bootstrap-navbar/version.rb
115
115
  - spec/bootstrap-navbar/helpers/bootstrap2_spec.rb
116
116
  - spec/bootstrap-navbar/helpers/bootstrap3_spec.rb
117
- - spec/bootstrap-navbar/helpers_spec.rb
118
117
  - spec/helpers.rb
119
118
  - spec/spec_helper.rb
120
119
  homepage: https://github.com/krautcomputing/bootstrap-navbar
@@ -144,7 +143,6 @@ summary: Helpers to generate a Twitter Bootstrap style navbar
144
143
  test_files:
145
144
  - spec/bootstrap-navbar/helpers/bootstrap2_spec.rb
146
145
  - spec/bootstrap-navbar/helpers/bootstrap3_spec.rb
147
- - spec/bootstrap-navbar/helpers_spec.rb
148
146
  - spec/helpers.rb
149
147
  - spec/spec_helper.rb
150
148
  has_rdoc:
File without changes