Sha256: 9e7051846e8d62f9b087545285866669e19b08b5f0528c0d76cbc4c20df58196

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

# frozen_string_literal: true

module Bridgetown
  module LiquidExtensions
    # Lookup a Liquid variable in the given context.
    #
    # @param context [Liquid::Context]
    # @param variable [String] the variable name
    # @return [Object] 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

1 entries across 1 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta3 lib/bridgetown-core/liquid_extensions.rb