Sha256: d69d4c167ec9b384e8ce01e48c9c29738d99e7cb647f799b418ae9b8c2d78741

Contents?: true

Size: 530 Bytes

Versions: 83

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

module Bridgetown
  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

83 entries across 83 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta2 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-2.0.0.beta1 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.4 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.3 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.2 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.1 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.0 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.0.beta3 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.0.beta2 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.3.0.beta1 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0.beta5 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0.beta4 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0.beta3 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0.beta2 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.2.0.beta1 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.1.0 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.1.0.beta3 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.1.0.beta2 lib/bridgetown-core/liquid_extensions.rb
bridgetown-core-1.1.0.beta1 lib/bridgetown-core/liquid_extensions.rb