link_to_active_state 1.0.5 → 1.0.6
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.
@@ -20,6 +20,7 @@ module LinkToActiveState
|
|
20
20
|
|
21
21
|
link_options ||= {}
|
22
22
|
html_options ||= {}
|
23
|
+
wrapper_options = html_options.delete(:active_wrapper_options) || {}
|
23
24
|
|
24
25
|
if html_options.present? && html_options[:active_on].present?
|
25
26
|
active_on = html_options.delete(:active_on)
|
@@ -36,9 +37,12 @@ module LinkToActiveState
|
|
36
37
|
end
|
37
38
|
|
38
39
|
if html_options.present? && html_options[:active_wrapper]
|
40
|
+
if wrapper_options[:class].present?
|
41
|
+
options[:class] = merge_class(wrapper_options[:class], options[:class])
|
42
|
+
end
|
43
|
+
|
39
44
|
element_or_proc = html_options.delete(:active_wrapper)
|
40
|
-
wrapper_options
|
41
|
-
wrapper_options = wrapper_options.merge(options)
|
45
|
+
wrapper_options.merge!(options)
|
42
46
|
|
43
47
|
render_with_wrapper(element_or_proc, wrapper_options) do
|
44
48
|
link_to_without_active_state(*args, &block)
|
@@ -101,6 +101,17 @@ describe LinkToActiveState::ViewHelpers::UrlHelper do
|
|
101
101
|
li.should match(/<li class=\"active\">/i)
|
102
102
|
li.should match(/<a href/i)
|
103
103
|
end
|
104
|
+
|
105
|
+
it "supports options on proc wrapper elements" do
|
106
|
+
request.stub!(:fullpath).and_return("/")
|
107
|
+
li = helper.link_to "Home", "/",
|
108
|
+
:active_on => "/",
|
109
|
+
:active_wrapper_options => { :class => "wibble" },
|
110
|
+
:active_wrapper => proc { |link, wrapper_options|
|
111
|
+
"<li class=\"#{wrapper_options[:class]}\">#{link}</li>"
|
112
|
+
}
|
113
|
+
li.should match(/<li class=\"wibble active\">/i)
|
114
|
+
end
|
104
115
|
end
|
105
116
|
end
|
106
117
|
end
|