Sha256: fe07afac50fcfd5e208d549352ad5632145736aa10e6d999d8e270a161c9752d

Contents?: true

Size: 881 Bytes

Versions: 4

Compression:

Stored size: 881 Bytes

Contents

module Jekyll
  module LanguagePlugin
    module Tags
      class LanguageIncludeTag < Jekyll::Tags::IncludeTag
        def tag_includes_dir(context)
          (context.registers[:site].config['language_includes_dir'].to_s || '_i18n').freeze
        end

        def page_language(context)
          if context.registers[:page].nil? || context.registers[:page]['language'].to_s.empty?
            raise Jekyll::LanguagePlugin::PluginError.new('No language specified for current page or post.')
          end
          context.registers[:page].nil? ? "." : context.registers[:page]["language"]
        end

        def resolved_includes_dir(context)
          File.join(context.registers[:site].in_source_dir(@includes_dir), page_language(context))
        end
      end
    end
  end
end

Liquid::Template.register_tag('tinclude', Jekyll::LanguagePlugin::Tags::LanguageIncludeTag)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.2.3 lib/jekyll/language-plugin/tags/language_include.rb
jekyll-language-plugin-1.2.2 lib/jekyll/language-plugin/tags/language_include.rb
jekyll-language-plugin-1.2.0 lib/jekyll/language-plugin/tags/language_include.rb
jekyll-language-plugin-1.1.8 lib/jekyll/language-plugin/tags/language_include.rb