Class: Occams::Content::Tag::Breadcrumbs

Inherits:
Occams::Content::Tag show all
Defined in:
lib/occams/content/tags/breadcrumbs.rb

Overview

Nav Tag for rendering breadcrumb links to current page

{{ cms:breadcrumbs }}
{{ cms:breadcrumbs style: "font-weight: bold" }}

To customize your breadcrumbs style, add a ‘breadcrumbs’ id to your CSS, e.g #breadcrumbs

color: #006633;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 105%;
font-weight: bold;
margin-top: 12px;
margin-bottom: 4px;
font-style: italic;

and/or pass in style overrides with the ‘style’ parameter, as above

Instance Attribute Summary collapse

Attributes inherited from Occams::Content::Tag

#context, #params, #source

Instance Method Summary collapse

Methods inherited from Occams::Content::Tag

#allow_erb?, #nodes, #render

Constructor Details

#initialize(context:, params: [], source: nil) ⇒ Breadcrumbs

Returns a new instance of Breadcrumbs.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/occams/content/tags/breadcrumbs.rb', line 21

def initialize(context:, params: [], source: nil)
  super
  @locals = params.extract_options!
  @style = ''
  @style = "<style>#breadcrumbs {#{@locals['style']}}</style>" if @locals['style']

  @links = '<div id="breadcrumbs">'
  context.ancestors.reverse.each do |a|
    next if Rails.env == 'production' && !a.is_published

    @links += "<a href=#{a.url(relative: true)}>#{a.label}</a> &raquo; "
  end
  @links += "#{context.label}</div>"
end

Instance Attribute Details

Returns the value of attribute links.



19
20
21
# File 'lib/occams/content/tags/breadcrumbs.rb', line 19

def links
  @links
end

#localsObject (readonly)

Returns the value of attribute locals.



19
20
21
# File 'lib/occams/content/tags/breadcrumbs.rb', line 19

def locals
  @locals
end

#styleObject (readonly)

Returns the value of attribute style.



19
20
21
# File 'lib/occams/content/tags/breadcrumbs.rb', line 19

def style
  @style
end

Instance Method Details

#contentObject



36
37
38
# File 'lib/occams/content/tags/breadcrumbs.rb', line 36

def content
  format("#{@style}#{@links}")
end