Sha256: 0fe80579a4988f772310a240d5c26bc9847be79acbdbc0f38f705ef53ce89448

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 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 --------------------------------------------------------------------
start_tag = "<ul"
start_tag << " class=\"#{context[:config]['tag.menu.css_class']}\"" if context[:config]['tag.menu.css_class']
start_tag << ">"

nested_list = lambda do |nodes, level|
  out = (level == 1 ? start_tag.dup : "<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?, context[:config])
    out << "<li #{style}>#{link}"
    out << menu
    out << "</li>"
  end
  out << "</ul>"
  out
end

flat_list = lambda do |nodes, level|
  submenu = ''
  out = (level == 1 ? start_tag.dup : "<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?, context[:config])
    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 data/webgen/passive_sources/templates/tag.template