Module: CrumbsHelper

Defined in:
app/helpers/crumbs_helper.rb

Instance Method Summary collapse

Instance Method Details

breadcrumb(“Home” => “/”, “Blog” => [:site, :blog], @post.title => request.path )



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
# File 'app/helpers/crumbs_helper.rb', line 5

def breadcrumb(crumbs = {})
  crumbs = crumbs.to_a
  buff = ""
  buff << '<ul class="breadcrumb">'
  active = crumbs.pop
  crumbs.each do |title, path|
    path = !path.is_a?(String) ? polymorphic_path(path) : h(path)
    
    buff << "    <li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\">\n      <a itemprop=\"url\" href=\"\#{path}\">\n        <span itemprop=\"title\">\#{h(title)}</span>\n      </a> \n      <span class=\"divider\">/</span>\n    </li>\n    eos\n    \n  end\n  \n  title, path = active\n  path = !path.is_a?(String) ? polymorphic_path(path) : h(path)\n  \n  buff << <<-eos\n    <li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\" class=\"active\">\n      <a itemprop=\"url\" href=\"\#{path}\">\n        <span itemprop=\"title\">\#{h(title)}</span>\n      </a> \n    </li>\n    eos\n  \n  \n  buff << '</ul>'\n  content_for( :breadcrumb,  buff.html_safe )\n  nil\nend\n"