This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
forked from danielharan/semantic-menu
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
54 lines (43 loc) · 1.3 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
= SemanticMenu
A plugin to make large menus easier to write.
Supports arbitrarily deep nesting; parents will be marked as 'active' if any of its children are active.
== Example
<%= semantic_menu do |root|
root.add "overview", root_path
root.add "comments", comments_path
end %>
Assuming you are on /comments, the output would be:
<ul class="menu">
<li>
<a href="/">overview</a>
</li>
<li class="active">
<a href="/comments">comments</a>
</li>
</ul>
add and semantic_menu both take an optional parameter hash, and you can nest the menu as deeply as you want:
<%= semantic_menu :class => 'top_level_nav' do |root|
root.add "overview", "root_path"
root.add "comments", "comments_path", :class => 'button' do |comments|
comments.add "My Comments", "my_comments_path"
comments.add "Recent", "recent_comments_path"
end
end %>
This would look like this:
<ul class="top_level_nav">
<li>
<a href="root_path">overview</a>
</li>
<li class="active">
<a href="comments_path" class="button">comments</a>
<ul class="menu_level_1">
<li class="active">
<a href="my_comments_path">My Comments</a>
</li>
<li>
<a href="recent_comments_path">Recent</a>
</li>
</ul>
</li>
</ul>
Copyright (c) 2008 Daniel Haran, released under the MIT license