nutmeg 0.0.10 → 0.0.11
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/lib/nutmeg/tag_tree_helper.rb +6 -7
- data/lib/nutmeg/version.rb +1 -1
- data/spec/tag_tree_helper_spec.rb +7 -0
- 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: e37875ea673b1b17788595a4498cf49a225ccd9a
|
4
|
+
data.tar.gz: 0ed69982fee93ef14494a6b2c3ba36468cd7abb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b21a83abfbb1905df9e9a207c816a0015324ff0d441e2fe24f75f1fa72ad96f66f5af42649e8c64ec93d01b9e3f0c032da471e1f7ea1ed4b84c8b5a860c7716
|
7
|
+
data.tar.gz: 578e03eccafb6f30dba1ff7a5ea3e69be552c3b840a5125feeb2a139dd603350b202860a291aa084a6e966e3d7240a94669e833bbebf442800a25231ab0fb0f2
|
@@ -18,9 +18,8 @@ module Nutmeg
|
|
18
18
|
def title(node)
|
19
19
|
node.content[:name] || node.content[:slug]
|
20
20
|
end
|
21
|
-
|
22
|
-
|
23
|
-
[print_node(@tree.original, tags_given, greedy, extra_html)].join("")
|
21
|
+
def print_html(tags_given, greedy = false, extra_html = nil, do_not_wrap = false)
|
22
|
+
[print_node(@tree.original, tags_given, greedy, extra_html, do_not_wrap)].join("")
|
24
23
|
end
|
25
24
|
|
26
25
|
def node_html(node, active, leaf, content, extra_html = nil)
|
@@ -31,7 +30,7 @@ module Nutmeg
|
|
31
30
|
([""] + node.parentage.map{|p| p.content[:slug]}.reverse.reject{|n| n == "root"} + [node.content[:slug]]).join("/")
|
32
31
|
end
|
33
32
|
|
34
|
-
def print_node(node, tags_given, greedy = false, extra_html = nil)
|
33
|
+
def print_node(node, tags_given, greedy = false, extra_html = nil, do_not_wrap = false)
|
35
34
|
output = []
|
36
35
|
|
37
36
|
if render_node?(node,tags_given)
|
@@ -43,11 +42,11 @@ module Nutmeg
|
|
43
42
|
return output
|
44
43
|
end
|
45
44
|
if node.has_children?
|
46
|
-
output << "<ul>"
|
45
|
+
output << (do_not_wrap && node.is_root? ? "" : "<ul>")
|
47
46
|
node.children.each do |child|
|
48
|
-
output << print_node(child, tags_given, greedy,extra_html)
|
47
|
+
output << print_node(child, tags_given, greedy,extra_html, do_not_wrap)
|
49
48
|
end
|
50
|
-
output << "</ul>"
|
49
|
+
output << (do_not_wrap && node.is_root? ? "" : "</ul>")
|
51
50
|
end
|
52
51
|
if render_node?(node,tags_given)
|
53
52
|
output << "</li>"
|
data/lib/nutmeg/version.rb
CHANGED
@@ -32,9 +32,16 @@ describe Nutmeg::TagTreeHelper do
|
|
32
32
|
it "renders additional content in the leaf" do
|
33
33
|
subtree = @tree_from_json.tree
|
34
34
|
expect(Nutmeg::TagTreeHelper.new(subtree, {:prepend_path => "/nl/t"}).print_html(["north", "men", "footwear"],false, "<a href='#'>Extra content</a>")).to eq("<ul><li class='level_1 active'> <a >North</a><ul><li class='level_2 active'> <a >Men</a><ul><li class='level_3 leaf active'> <a href='/nl/t/north/men/footwear'>Footwear</a><a href='#'>Extra content</a></li><li class='level_3 leaf'> <a href='/nl/t/north/men/eyewear'>Eyewear</a></li></ul></li><li class='level_2'> <a >Women</a><ul><li class='level_3 leaf'> <a href='/nl/t/north/women/footwear'>Footwear</a></li><li class='level_3'> <a >Eyewear</a><ul><li class='level_4 leaf'> <a href='/nl/t/north/women/eyewear/gfdgdfs'>gfdgdfs</a></li></ul></li></ul></li><li class='level_2 leaf'> <a href='/nl/t/north/collaboration'>Collaboration</a></li></ul></li><li class='level_1'> <a >South</a><ul><li class='level_2'> <a >Men</a><ul><li class='level_3 leaf'> <a href='/nl/t/south/men/collection'>Collection</a></li><li class='level_3 leaf'> <a href='/nl/t/south/men/footwear'>Footwear</a></li><li class='level_3 leaf'> <a href='/nl/t/south/men/eyewear'>Eyewear</a></li></ul></li><li class='level_2'> <a >Women</a><ul><li class='level_3 leaf'> <a href='/nl/t/south/women/collection'>Collection</a></li><li class='level_3 leaf'> <a href='/nl/t/south/women/footwear'>Footwear</a></li><li class='level_3 leaf'> <a href='/nl/t/south/women/eyewear'>Eyewear</a></li></ul></li><li class='level_2 leaf'> <a href='/nl/t/south/collaboration'>Collaboration</a></li></ul></li></ul>")
|
35
|
+
end
|
36
|
+
end
|
35
37
|
|
38
|
+
context "Wrapping ul element" do
|
39
|
+
it "do not return wrapping ul" do
|
40
|
+
subtree = @tree_from_json.tree
|
41
|
+
expect(Nutmeg::TagTreeHelper.new(subtree, {:prepend_path => "/nl/t"}).print_html(["north", "men", "footwear"],false, "<a href='#'>Extra content</a>", true)).to eq("<li class='level_1 active'> <a >North</a><ul><li class='level_2 active'> <a >Men</a><ul><li class='level_3 leaf active'> <a href='/nl/t/north/men/footwear'>Footwear</a><a href='#'>Extra content</a></li><li class='level_3 leaf'> <a href='/nl/t/north/men/eyewear'>Eyewear</a></li></ul></li><li class='level_2'> <a >Women</a><ul><li class='level_3 leaf'> <a href='/nl/t/north/women/footwear'>Footwear</a></li><li class='level_3'> <a >Eyewear</a><ul><li class='level_4 leaf'> <a href='/nl/t/north/women/eyewear/gfdgdfs'>gfdgdfs</a></li></ul></li></ul></li><li class='level_2 leaf'> <a href='/nl/t/north/collaboration'>Collaboration</a></li></ul></li><li class='level_1'> <a >South</a><ul><li class='level_2'> <a >Men</a><ul><li class='level_3 leaf'> <a href='/nl/t/south/men/collection'>Collection</a></li><li class='level_3 leaf'> <a href='/nl/t/south/men/footwear'>Footwear</a></li><li class='level_3 leaf'> <a href='/nl/t/south/men/eyewear'>Eyewear</a></li></ul></li><li class='level_2'> <a >Women</a><ul><li class='level_3 leaf'> <a href='/nl/t/south/women/collection'>Collection</a></li><li class='level_3 leaf'> <a href='/nl/t/south/women/footwear'>Footwear</a></li><li class='level_3 leaf'> <a href='/nl/t/south/women/eyewear'>Eyewear</a></li></ul></li><li class='level_2 leaf'> <a href='/nl/t/south/collaboration'>Collaboration</a></li></ul></li>")
|
36
42
|
end
|
37
43
|
end
|
44
|
+
|
38
45
|
end
|
39
46
|
|
40
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nutmeg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis van der Vliet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubytree
|