Sha256: 95ca0ee4f8ea182f45514766ec8a7f4632892a15cf892b28be58fc8342fbe1fd

Contents?: true

Size: 518 Bytes

Versions: 5

Compression:

Stored size: 518 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
bunto-3.4.5 lib/bunto/liquid_extensions.rb
bunto-3.2.1 lib/bunto/liquid_extensions.rb
bunto-3.0.0 lib/bunto/liquid_extensions.rb
bunto-2.0.0.pre lib/bunto/liquid_extensions.rb
bunto-1.0.0 lib/bunto/liquid_extensions.rb