Class: Webgen::Tag::BreadcrumbTrail
- Inherits:
-
Object
- Object
- Webgen::Tag::BreadcrumbTrail
- Includes:
- Base, WebsiteAccess
- Defined in:
- lib/webgen/tag/breadcrumbtrail.rb
Overview
Generates a breadcrumb trail for the page. This is especially useful when pages are in deep hierarchies of directories.
Instance Method Summary collapse
-
#call(tag, body, context) ⇒ Object
Create the breadcrumb trail.
-
#initialize ⇒ BreadcrumbTrail
constructor
:nodoc:.
Methods included from Base
#create_tag_params, #param, #set_params
Methods included from WebsiteAccess
Methods included from Loggable
Constructor Details
#initialize ⇒ BreadcrumbTrail
:nodoc:
12 13 14 |
# File 'lib/webgen/tag/breadcrumbtrail.rb', line 12 def initialize #:nodoc: website.blackboard.add_listener(:node_changed?, method(:node_changed?)) end |
Instance Method Details
#call(tag, body, context) ⇒ Object
Create the breadcrumb trail.
17 18 19 20 21 22 23 24 |
# File 'lib/webgen/tag/breadcrumbtrail.rb', line 17 def call(tag, body, context) out = (context.content_node) (context.dest_node.node_info[:tag_breadcrumb_trail] ||= {})[[@params.to_a.sort, context.content_node.absolute_lcn]] = out.map {|n| n.absolute_lcn} out = out.map {|n| context.dest_node.link_to(n, :lang => context.content_node.lang) }. join(param('tag.breadcrumbtrail.separator')) log(:debug) { "Breadcrumb trail for <#{context.content_node.absolute_lcn}>: #{out}" } out end |