Module: Webgen::Tag::Menu
- Defined in:
- lib/webgen/tag/menu.rb
Overview
Generates a menu that can be extensively configured by using the available Webgen::NodeFinder options.
Class Method Summary collapse
-
.call(tag, body, context) ⇒ Object
Generate the menu.
-
.menu_item_details(dest_node, node, lang, level, has_submenu, config) ⇒ Object
Return style information (node is selected, …) and a link from
dest_node
tonode
.
Class Method Details
.call(tag, body, context) ⇒ Object
Generate the menu.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/webgen/tag/menu.rb', line 13 def self.call(tag, body, context) = context[:config]['tag.menu.options'] context[:nodes] = context.website.ext.node_finder.find(, context.content_node) context.website.ext.item_tracker.add(context.dest_node, :nodes, :node_finder_option_set, {:opts => , :ref_alcn => context.content_node.alcn}, context[:config]['tag.menu.tracking_style']) if context[:nodes].empty? '' else Webgen::Tag.render_tag_template(context, "menu") end end |
.menu_item_details(dest_node, node, lang, level, has_submenu, config) ⇒ Object
Return style information (node is selected, …) and a link from dest_node
to node
.
This method can be used in a menu template.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/webgen/tag/menu.rb', line 31 def self.(dest_node, node, lang, level, , config) styles = [config['tag.menu.item_level_class'] + level.to_s] styles << config['tag.menu.item_submenu_class'] if styles << config['tag.menu.item_submenu_inhierarchy_class'] if node.is_ancestor_of?(dest_node) styles << config['tag.menu.item_selected_class'] if node == dest_node style = "class=\"#{styles.join(' ')}\"" if styles.length > 0 link = dest_node.link_to(node, lang) [style, link] end |