Sha256: 7fe4089b279d24d839358b6a06988f7514a882d024e443b783542bd28c2c1c83

Contents?: true

Size: 756 Bytes

Versions: 1

Compression:

Stored size: 756 Bytes

Contents

require 'webgen/tag'

module Webgen::Tag

  # Generates a list with all the languages of the page.
  class Langbar

    include Webgen::Tag::Base

    # Return a list of all translations of the content page.
    def call(tag, body, context)
      lang_nodes = context.content_node.tree.node_access[:acn][context.content_node.absolute_cn]
      nr_langs = lang_nodes.length
      result = lang_nodes.
        reject {|n| (context.content_node.lang == n.lang && !param('tag.langbar.show_own_lang')) }.
        sort {|a, b| a.lang <=> b.lang}.
        collect {|n| context.dest_node.link_to(n, :link_text => n.lang)}.
        join(param('tag.langbar.separator'))
      (param('tag.langbar.show_single_lang') || nr_langs > 1 ? result : "")
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webgen-0.5.1 lib/webgen/tag/langbar.rb