nav_link_to 0.0.3 → 0.0.4
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.
- data/README.md +1 -1
- data/lib/nav_link_to.rb +7 -3
- data/lib/nav_link_to/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
nav_link_to 'Home', root_path
|
22
22
|
nav_link_to 'Home', root_path, 'myClass'
|
23
23
|
nav_link_to 'Home', root_path, nil, id:'myId'
|
24
|
-
|
24
|
+
# Class is a necessary param if you want to use another attribute after, but you can set it 'nil'
|
25
25
|
|
26
26
|
|
27
27
|
will return
|
data/lib/nav_link_to.rb
CHANGED
@@ -2,15 +2,19 @@ require "nav_link_to/version"
|
|
2
2
|
|
3
3
|
module NavLinkTo
|
4
4
|
|
5
|
-
def nav_link_to(text, path, css_class=nil,
|
5
|
+
def nav_link_to(text, path, css_class=nil, li_properties = {}, a_properties = {})
|
6
6
|
|
7
|
-
|
7
|
+
lp = li_properties.collect do |k, v|
|
8
|
+
%( #{k}="#{v}") unless k == :class
|
9
|
+
end.join
|
10
|
+
|
11
|
+
ap = a_properties.collect do |k, v|
|
8
12
|
%( #{k}="#{v}") unless k == :class
|
9
13
|
end.join
|
10
14
|
|
11
15
|
tag_class = %( class="#{css_class unless css_class.nil? }#{' ' if current_page? path and !css_class.nil?}#{'active' if current_page? path}") if current_page? path or !css_class.nil?
|
12
16
|
|
13
|
-
%(<li#{tag_class}#{
|
17
|
+
%(<li#{tag_class}#{lp}>#{link_to text, path, a_properties}</li>).html_safe
|
14
18
|
|
15
19
|
end
|
16
20
|
|
data/lib/nav_link_to/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nav_link_to
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create link inside <li> element and gives it a 'active' class if current
|
15
15
|
page
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
50
|
+
rubygems_version: 1.8.24
|
51
51
|
signing_key:
|
52
52
|
specification_version: 3
|
53
53
|
summary: Create a menu link
|