Sha256: 0f61ca225f245191961ea15893af4fcf9b5be40c3c154226d6a03d306cfbfff2

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Jekyll
  module LanguagePlugin
    module Loaders
      class BaseLoader
        attr_reader :site

        def initialize(site)
          @site = site
          @is_loaded = false
        end

        def loaded?(language)
          true
        end

        def load(language)
          true
        end

        def get(key, language)
          nil
        end

        def get_with_placeholders(key, tokens, language)
          res = get(key, language)
          return nil if res.nil?
          res.gsub(/%%/).with_index { |m, i| tokens[i] || m }
        end

        def traverse_hash(hash, keys)
          for key in keys
            return hash unless hash.is_a?(Hash)
            return nil unless hash.key?(key)
            hash = hash[key]
          end
          hash
        end

        def resolve_dot_notation(keys)
          return keys.split('.') if keys.is_a?(String)
          return [] if !keys.is_a?(Enumerable)

          keys.flat_map do |key|
            resolve_dot_notation(key)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-language-plugin-1.2.3 lib/jekyll/language-plugin/loaders/base_loader.rb