Class: Textigniter::Plugins::Breadcrumbs

Inherits:
Object
  • Object
show all
Defined in:
lib/textigniter/plugins/breadcrumbs.rb

Instance Method Summary collapse

Instance Method Details

#parse(h) ⇒ Object



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
# File 'lib/textigniter/plugins/breadcrumbs.rb', line 3

def parse(h)
  value = "#{h['breadcrumbs']}"
  value.gsub!("#{$twd}/content/", '')

  unless value == "index"
    # begin breadcrumbs
    breadcrumbs = "<a href=\"#{$config['site_url']}\" class=\"home\">Home</a>"
    # split the string by /
    values = value.split(/\//)
    # current page
    current = values.last
    # remove current from values
    values.pop
    
    values.each do |v|
      breadcrumbs << " | <a href=\"#{$config['site_url']}/#{v}\">#{v}</a>"
    end
    
    breadcrumbs << " | <span class=\"current\">#{h['title']}</span>"
    
  else
    breadcrumbs = "Home"
  end
  
  return breadcrumbs
  
end