Sha256: d4aeb4e8bdc2f1bd42a224f8ac66037d00ff79a59e37368ec7b206db07a2d37b

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

--- name:tag.langbar pipeline:ruby ------------------------------------------------------------------
context.content = context[:nodes].map do |node|
  attrs = {:link_text => node.lang}
  attrs['class'] = 'webgen-langbar-current-lang' if context.content_node.lang == node.lang
  context.dest_node.link_to(node, node.lang, attrs)
end.join(context[:config]['tag.langbar.separator'])


--- name:tag.breadcrumb_trail pipeline:ruby --------------------------------------------------------
context.content = context[:nodes].map do |node|
  context.dest_node.link_to(node, context.dest_node.lang)
end.join(context[:config]['tag.breadcrumb_trail.separator'])


--- name:tag.menu pipeline:ruby --------------------------------------------------------------------
nested_list = lambda do |nodes, level|
  out = "<ul>"
  nodes.each do |node, children|
    menu = (children ? nested_list.call(children, level + 1) : '')
    style, link = Webgen::Tag::Menu.menu_item_details(context.dest_node, node, context.content_node.lang, level, !children.nil?)
    out << "<li #{style}>#{link}"
    out << menu
    out << "</li>"
  end
  out << "</ul>"
  out
end

flat_list = lambda do |nodes, level|
  submenu = ''
  out = "<ul>"
  nodes.each do |node, children|
    submenu << (children ? flat_list.call(children, level + 1) : '')
    style, link = Webgen::Tag::Menu.menu_item_details(context.dest_node, node, context.content_node.lang, level, !children.nil?)
    out << "<li #{style}>#{link}</li>"
  end
  out << "</ul>" << submenu
  out
end

generator = (context[:config]['tag.menu.style'] == 'nested' ? nested_list : flat_list)
context.content = generator.call(context[:nodes], 1)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-1.0.0.beta1 data/webgen/passive_sources/templates/tag.template