nav_links 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -6
- data/lib/nav_links/version.rb +1 -1
- data/lib/nav_links/view_helpers.rb +4 -2
- data/spec/helpers/nav_links_spec.rb +16 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c83c3166e65ec953386d185e6946029484cdae99
|
4
|
+
data.tar.gz: 209a7c45549b7b6cfcce91dccd54480aab097c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dffc9c4c7888647e50454138f284552844551027c51dc6e22046b4eb4dd32efacae16b68e090ee7c3d95299292629cbcec4bacb27d6bd695df0663c44c44ba05
|
7
|
+
data.tar.gz: d40a26e3d4112a3e054795257032b706d92178ed73f51acebd332dbbfefb847f8c5ffe4fc5f07d5bdf77cf5f53d33befab92fd93f820825af80da310d309d9ae
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Behold, the NavLinks:
|
2
2
|
|
3
3
|
[](https://travis-ci.org/bxt/wptemplates)
|
4
|
+
[](http://badge.fury.io/rb/nav_links)
|
4
5
|
|
5
|
-
Gem. Rails. Nav links. The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link. Just replace `link_to` with `nav_link_to` in your templates.
|
6
|
+
Gem. Rails. Nav links. The nav_link_to helper works just like the standard Rails link_to helper, but adds a 'selected' class to your link (or its wrapper) if certain criteria are met. By default, if the link's destination url is the same url as the url of the current page, a default class of 'selected' is added to the link. Just replace `link_to` with `nav_link_to` in your templates.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -36,13 +37,13 @@ Same usage as `link_to`:
|
|
36
37
|
|
37
38
|
### Group links with same options
|
38
39
|
|
39
|
-
You can reduce duplication and wrap `nav_link_to` calls with the same options with a call to `nav_links` like this:
|
40
|
+
You can reduce duplication and wrap `nav_link_to` calls with the same options with a call to `nav_links` like this:
|
40
41
|
|
41
42
|
<ul class="nav">
|
42
|
-
<% nav_links url_segment: 1, wrapper: 'li', selected_class:'active' do |
|
43
|
-
<%=
|
44
|
-
<%=
|
45
|
-
<%=
|
43
|
+
<% nav_links url_segment: 1, wrapper: 'li', selected_class:'active' do |nav| %>
|
44
|
+
<%= nav.link_to "Projects", projects_path %>
|
45
|
+
<%= nav.link_to "People", people_path %>
|
46
|
+
<%= nav.link_to "About", about_path %>
|
46
47
|
<% end %>
|
47
48
|
</ul>
|
48
49
|
|
data/lib/nav_links/version.rb
CHANGED
@@ -21,15 +21,17 @@ module NavLinks
|
|
21
21
|
@options = options
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def link_to(*args, &block)
|
25
25
|
index = block_given? ? 2 : 3
|
26
26
|
args[index] = @options.merge(args[index] || {})
|
27
27
|
|
28
28
|
@base.nav_link_to(*args, &block)
|
29
29
|
end
|
30
30
|
|
31
|
+
alias_method :nav_link_to, :link_to # deprecated, remove in 2.x
|
32
|
+
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
ActionView::Base.send :include, NavLinks::ViewHelpers
|
37
|
+
ActionView::Base.send :include, NavLinks::ViewHelpers
|
@@ -14,8 +14,17 @@ describe NavLinks::ViewHelpers do
|
|
14
14
|
NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
|
15
15
|
.and_return(link_generator)
|
16
16
|
|
17
|
-
helper.nav_links do |
|
18
|
-
|
17
|
+
helper.nav_links do |nav|
|
18
|
+
nav.link_to("My Title", "/path")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'supports the deprecated method name with nav_ prefix' do
|
23
|
+
NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {})
|
24
|
+
.and_return(link_generator)
|
25
|
+
|
26
|
+
helper.nav_links do |nav|
|
27
|
+
nav.nav_link_to("My Title", "/path")
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
@@ -23,8 +32,8 @@ describe NavLinks::ViewHelpers do
|
|
23
32
|
NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :bar})
|
24
33
|
.and_return(link_generator)
|
25
34
|
|
26
|
-
helper.nav_links foo: :bar do |
|
27
|
-
|
35
|
+
helper.nav_links foo: :bar do |nav|
|
36
|
+
nav.link_to("My Title", "/path")
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
@@ -32,11 +41,11 @@ describe NavLinks::ViewHelpers do
|
|
32
41
|
NavLinks::LinkGenerator.should_receive(:new).with(:request, "My Title", "/path", {}, {foo: :baz})
|
33
42
|
.and_return(link_generator)
|
34
43
|
|
35
|
-
helper.nav_links foo: :bar do |
|
36
|
-
|
44
|
+
helper.nav_links foo: :bar do |nav|
|
45
|
+
nav.link_to("My Title", "/path", {}, {foo: :baz})
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
40
49
|
end
|
41
50
|
|
42
|
-
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nav_links
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernhard Häussner
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-09
|
14
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|