breadcrumb 0.0.2 → 0.0.3
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.rdoc +44 -11
- data/lib/breadcrumb/helper.rb +6 -1
- data/lib/breadcrumb/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,26 +1,31 @@
|
|
1
1
|
= Breadcrumb
|
2
2
|
|
3
3
|
= Instalation
|
4
|
-
Put the following line in your Gemfile
|
5
|
-
gem "breadcrumb"
|
6
|
-
|
4
|
+
Put the following line in your Gemfile
|
5
|
+
gem "breadcrumb"
|
6
|
+
|
7
7
|
= Usage
|
8
8
|
|
9
9
|
Layout:
|
10
|
-
<%=
|
11
|
-
|
10
|
+
<%= breadcrumb %>
|
11
|
+
|
12
12
|
You can add a root path by doing this
|
13
|
-
|
13
|
+
|
14
14
|
<%= raw breadcrumb.prepend("Home","/") %>
|
15
|
-
|
15
|
+
|
16
16
|
In your view (say the uri path is /books/religion/the-holly-bible):
|
17
|
+
|
18
|
+
```ruby
|
17
19
|
<%
|
18
20
|
breadcrumb.add("Books","/books")
|
19
21
|
breadcrumb.add("Religion", books_category_path(@book.category))
|
20
22
|
breadcrumb.add(@book.title)
|
21
23
|
%>
|
24
|
+
```
|
22
25
|
|
23
26
|
It will render
|
27
|
+
|
28
|
+
```html
|
24
29
|
<div class="breadcrumb">
|
25
30
|
<a href="/books">Books</a>
|
26
31
|
<span class="separator"> » </span>
|
@@ -28,28 +33,56 @@ It will render
|
|
28
33
|
<span class="separator"> » </span>
|
29
34
|
<span>The Holly Bible</span>
|
30
35
|
</div>
|
36
|
+
```
|
31
37
|
|
32
38
|
You can change the separator
|
39
|
+
|
40
|
+
```ruby
|
33
41
|
breadcrumb.separator = '<span class="separator"> > </span>'
|
42
|
+
```
|
34
43
|
|
35
44
|
Titleizing
|
36
45
|
You can use breadcrumb for creating the page title:
|
46
|
+
|
47
|
+
```html
|
37
48
|
<title><%= breadcrumb.titleize %></title>
|
38
|
-
|
49
|
+
```
|
50
|
+
|
39
51
|
which will ouput
|
52
|
+
|
53
|
+
|
54
|
+
```html
|
40
55
|
<title>Books :: Religion :: The Holly Bible</title>
|
41
|
-
|
56
|
+
```
|
57
|
+
|
42
58
|
Titleize accepts block. When using blocks, returning false removes the title part. Returing nil, won't change the behavior. Returning String changes the title part.
|
59
|
+
|
60
|
+
```html
|
43
61
|
<title><%= breadcrumb.titleize {|part| "Our Awesome Books" if parts == 'Books' } %></title>
|
62
|
+
```
|
63
|
+
|
44
64
|
Ouputs
|
65
|
+
|
66
|
+
```
|
45
67
|
<title>Our Awesome Books :: Religion :: The Holly Bible</title>
|
68
|
+
```
|
46
69
|
|
47
70
|
Removing the title part
|
71
|
+
|
72
|
+
```
|
48
73
|
<title><%= breadcrumb.titleize {|part| false if part == "Religion" } %></title>
|
49
|
-
or
|
74
|
+
<!-- or -->
|
50
75
|
<title><%= breadcrumb.titleize {|part, order| false if order == 1 } %></title>
|
76
|
+
```
|
77
|
+
|
51
78
|
Outputs
|
79
|
+
|
80
|
+
```html
|
52
81
|
<title>Books :: The Holly Bible</title>
|
53
|
-
|
82
|
+
```
|
83
|
+
|
54
84
|
And you can change the title separator:
|
85
|
+
|
86
|
+
```ruby
|
55
87
|
breadcrumb.title_separator = '-'
|
88
|
+
```
|
data/lib/breadcrumb/helper.rb
CHANGED
@@ -39,7 +39,7 @@ module Breadcrumb
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
html.length > 1 ? "<div class=\"breadcrumb\">#{html.join(separator)}</div>" : ""
|
42
|
+
html.length > 1 ? raw("<div class=\"breadcrumb\">#{html.join(separator)}</div>") : ""
|
43
43
|
end
|
44
44
|
|
45
45
|
# Given
|
@@ -89,6 +89,11 @@ module Breadcrumb
|
|
89
89
|
@title_separator ||= ' :: '
|
90
90
|
end
|
91
91
|
|
92
|
+
# raws the content
|
93
|
+
def raw(content)
|
94
|
+
ApplicationController.helpers.raw(content)
|
95
|
+
end
|
96
|
+
|
92
97
|
end # end of class
|
93
98
|
end
|
94
99
|
|
data/lib/breadcrumb/version.rb
CHANGED