fume-nav 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/fume/nav/nav_tag.rb +10 -4
- data/lib/fume/nav/version.rb +1 -1
- data/spec/fume/nav/nav_tag_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c45ffe7e4c5812fe2a4927b7d808ac629eb77ee
|
4
|
+
data.tar.gz: 6cd9c66ed7c1eab12fdce55d45f01b34d159eb2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5506d36fb10b07af80eb7ff98e89d6031ed89ca1a769e472e1ffd3ca938c645ee9025040e392c2a48d12e1c2e7a743f69728f67262f8c7568f936ab16835b0
|
7
|
+
data.tar.gz: 57fbd2557badcbfc3c81317284b13db85e6438470e2799951d4e29ce24f195f7d39912153ce5ef825ed27ea7affb9287ebfac99d9072390c59c1610a6ed74123
|
data/README.md
CHANGED
@@ -35,8 +35,8 @@ view.erb
|
|
35
35
|
<%= fume_nav @current do |n| %>
|
36
36
|
<div class="dropdown">
|
37
37
|
<%= n.link_to :show, "link_1", root_path, class: "link" %>
|
38
|
-
<%= n.
|
39
|
-
<%= link_to "link_2", root_path, class: "link #{
|
38
|
+
<%= n.apply_content :edit do |active_class| %>
|
39
|
+
<%= link_to "link_2", root_path, class: "link #{active_class || 'default'}" %>
|
40
40
|
<% end %>
|
41
41
|
</div>
|
42
42
|
<% end %>
|
data/lib/fume/nav/nav_tag.rb
CHANGED
@@ -38,11 +38,10 @@ module Fume
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
@empty = false
|
41
42
|
end
|
42
43
|
|
43
44
|
def apply(value, &block)
|
44
|
-
@empty = false
|
45
|
-
|
46
45
|
result = case value
|
47
46
|
when Regexp
|
48
47
|
value.match(current)
|
@@ -50,8 +49,15 @@ module Fume
|
|
50
49
|
value.to_s == current.to_s
|
51
50
|
end
|
52
51
|
|
53
|
-
block.call(
|
54
|
-
|
52
|
+
block.call(result ? active_class : nil)
|
53
|
+
end
|
54
|
+
|
55
|
+
def apply_content(value, &block)
|
56
|
+
@empty = false
|
57
|
+
|
58
|
+
apply(value) do |cls|
|
59
|
+
helper.capture(cls, &block)
|
60
|
+
end
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
data/lib/fume/nav/version.rb
CHANGED
@@ -29,4 +29,17 @@ RSpec.describe Fume::Nav::NavTag do
|
|
29
29
|
before { expect(context).to receive(:link_to).with("TEXT", [:root], hash_excluding(class: "active")) }
|
30
30
|
it { subject.link_to :foo, "TEXT", [:root] }
|
31
31
|
end
|
32
|
+
|
33
|
+
describe "#apply_content" do
|
34
|
+
context "then match" do
|
35
|
+
let(:current) { :foo }
|
36
|
+
before { expect(context).to receive(:capture).with("active") }
|
37
|
+
it { subject.apply_content(:foo) { |cls| } }
|
38
|
+
end
|
39
|
+
|
40
|
+
context "then not match" do
|
41
|
+
before { expect(context).to receive(:capture).with(nil) }
|
42
|
+
it { subject.apply_content(:foo) { |cls| } }
|
43
|
+
end
|
44
|
+
end
|
32
45
|
end
|