Module: Webgen::Tag::Langbar
- Defined in:
- lib/webgen/tag/langbar.rb
Overview
Generates a list with all the languages of the page.
Class Method Summary collapse
-
.call(tag, body, context) ⇒ Object
Return a rendering of the list of all translations of the content node.
-
.node_translations(website, node_alcn) ⇒ Object
Generate the list of node translations given the options.
Class Method Details
.call(tag, body, context) ⇒ Object
Return a rendering of the list of all translations of the content node.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/webgen/tag/langbar.rb', line 12 def self.call(tag, body, context) context.website.ext.item_tracker.add(context.dest_node, :nodes, ['Webgen::Tag::Langbar', 'node_translations'], context.content_node.alcn, :meta_info) nodes = node_translations(context.website, context.content_node.alcn) if context[:config]['tag.langbar.show_single_lang'] || nodes.length > 1 context[:nodes] = nodes. reject {|n| (context.content_node.lang == n.lang && !context[:config]['tag.langbar.show_own_lang'])}. sort {|a, b| a.lang <=> b.lang} Webgen::Tag.render_tag_template(context, 'langbar') else '' end end |
.node_translations(website, node_alcn) ⇒ Object
Generate the list of node translations given the options.
This method is invoked by Webgen::ItemTracker::NodeList to retrieve the translations nodes when necessary.
32 33 34 |
# File 'lib/webgen/tag/langbar.rb', line 32 def self.node_translations(website, node_alcn) website.tree.translations(website.tree[node_alcn]) end |