<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -188,44 +188,30 @@ module Liquid
       if object = find_variable(first_part)
 
         parts.each do |part|
+          part = resolve($1) if part_resolved = (part =~ square_bracketed)
 
-          # If object is a hash we look for the presence of the key and if its available
-          # we return it
+          # If object is a hash- or array-like object we look for the
+          # presence of the key and if its available we return it
+          if object.respond_to?(:[]) and
+            ((object.respond_to?(:has_key?) and object.has_key?(part)) or
+             (object.respond_to?(:fetch) and part.is_a?(Integer)))
 
-          if part =~ square_bracketed
-            part = resolve($1)
+            # if its a proc we will replace the entry with the proc
+            res = object[part]
+            res = object[part] = res.call(self) if res.is_a?(Proc) and object.respond_to?(:[]=)
+            object = res.to_liquid
 
-            object[pos] = object[part].call(self) if object[part].is_a?(Proc) and object.respond_to?(:[]=)
-            object      = object[part].to_liquid
+          # Some special cases. If the part wasn't in square brackets and
+          # no key with the same name was found we interpret following calls
+          # as commands and call them on the current object
+          elsif !part_resolved and object.respond_to?(part) and ['size', 'first', 'last'].include?(part)
 
-          else
-
-            # Hash
-            if object.respond_to?(:has_key?) and object.has_key?(part)
-
-              # if its a proc we will replace the entry in the hash table with the proc
-              res = object[part]
-              res = object[part] = res.call(self) if res.is_a?(Proc) and object.respond_to?(:[]=)
-              object = res.to_liquid
-
-            # Array
-            elsif object.respond_to?(:fetch) and part =~ /^\d+$/
-              pos = part.to_i
-
-              object[pos] = object[pos].call(self) if object[pos].is_a?(Proc) and object.respond_to?(:[]=)
-              object = object[pos].to_liquid
-
-            # Some special cases. If no key with the same name was found we interpret following calls
-            # as commands and call them on the current object
-            elsif object.respond_to?(part) and ['size', 'first', 'last'].include?(part)
+            object = object.send(part.intern).to_liquid
 
-              object = object.send(part.intern).to_liquid
-
-            # No key was present with the desired value and it wasn't one of the directly supported
-            # keywords either. The only thing we got left is to return nil
-            else
-              return nil
-            end
+          # No key was present with the desired value and it wasn't one of the directly supported
+          # keywords either. The only thing we got left is to return nil
+          else
+            return nil
           end
 
           # If we are dealing with a drop here we have to
@@ -235,11 +221,5 @@ module Liquid
 
       object
     end
-
-    private
-
-    def execute_proc(proc)
-      proc.call(self)
-    end
   end
 end</diff>
      <filename>lib/liquid/context.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>50edd0f5b92cc38f7da032fc0caea6dbdadd9f07</id>
    </parent>
  </parents>
  <author>
    <name>Mark H. Wilkinson</name>
    <email>mhw@dangerous-techniques.com</email>
  </author>
  <url>http://github.com/tobi/liquid/commit/7acdac2a1c771c92fb04fd208d11dae5aa7054dc</url>
  <id>7acdac2a1c771c92fb04fd208d11dae5aa7054dc</id>
  <committed-date>2008-07-09T10:46:38-07:00</committed-date>
  <authored-date>2008-07-09T00:23:51-07:00</authored-date>
  <message>Fix attribute expansion to index only once in all cases.

Also drop array.&lt;digits&gt; syntax</message>
  <tree>d8e77e85b454646ed8e3f5e5a8f07d306beea037</tree>
  <committer>
    <name>Mark H. Wilkinson</name>
    <email>mhw@dangerous-techniques.com</email>
  </committer>
</commit>
