Sha256: 9b0929234935ae75c2dcf796bc404d11c62eebe456a9b3000b5335df4b916a47
Contents?: true
Size: 1.25 KB
Versions: 12
Compression:
Stored size: 1.25 KB
Contents
module Octopress module Multilingual module Tags class Translations < Liquid::Tag def initialize(tag, input, tokens) super @tag = tag.strip @input = input.strip end def render(context) @context = context if translations if @tag == 'translation_list' list = translations.dup.map do |t| "<li translation-item lang-#{t.lang}'>#{anchor(t)}</li>" end.join(' ,') "<ul class='translation-list'>#{list}</uL>" else translations.dup.map do |t| anchor(t) end.join(', ') end end end def anchor(item) language = Octopress::Multilingual.language_name(item.lang) "<a class='translation-link lang-#{item.lang}' href='#{ item.url }'>#{ language }</a>" end def translations if item = @context[@input] item['translations'] if item['translated'] end end end end end end Liquid::Template.register_tag('translations', Octopress::Multilingual::Tags::Translations) Liquid::Template.register_tag('translation_list', Octopress::Multilingual::Tags::Translations)
Version data entries
12 entries across 12 versions & 1 rubygems