Sha256: c165159d3ec55fd8cc0269b21271006b465375e3ce81311ef4800ffb083cac26

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 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

2 entries across 2 versions & 2 rubygems

Version Path
jekyll-4.2.1 lib/jekyll/liquid_extensions.rb
ngage-0.0.0 lib/ngage/jekyll/liquid_extensions.rb