Sha256: a91a97aec92a84d2bf8f441e582f8d69273d0dbe9944ca487346ebba8a4b2c33

Contents?: true

Size: 526 Bytes

Versions: 13

Compression:

Stored size: 526 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module LiquidExtensions
    # Lookup a Liquid variable in the given context.
    #
    # context  - the Liquid context in question.
    # variable - the variable name, as a string.
    #
    # Returns the value of the variable in the context
    #   or the variable name if not found.
    def lookup_variable(context, variable)
      lookup = context

      variable.split(".").each do |value|
        lookup = lookup[value]
      end

      lookup || variable
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jekyll-4.3.4 lib/jekyll/liquid_extensions.rb
jekyll-4.3.3 lib/jekyll/liquid_extensions.rb
jekyll-4.3.2 lib/jekyll/liquid_extensions.rb
jekyll-4.3.1 lib/jekyll/liquid_extensions.rb
jekyll-4.3.0 lib/jekyll/liquid_extensions.rb
jekyll-4.2.2 lib/jekyll/liquid_extensions.rb
jekyll-4.2.0 lib/jekyll/liquid_extensions.rb
jekyll-4.1.1 lib/jekyll/liquid_extensions.rb
jekyll-4.1.0 lib/jekyll/liquid_extensions.rb
jekyll-4.0.1 lib/jekyll/liquid_extensions.rb
jekyll-4.0.0 lib/jekyll/liquid_extensions.rb
jekyll-4.0.0.pre.beta1 lib/jekyll/liquid_extensions.rb
jekyll-4.0.0.pre.alpha1 lib/jekyll/liquid_extensions.rb