0
@@ -188,44 +188,30 @@ module Liquid
0
if object = find_variable(first_part)
0
+ part = resolve($1) if part_resolved = (part =~ square_bracketed)
0
- # If object is a hash we look for the presence of the key and if its available
0
+ # If object is a hash- or array-like object we look for the
0
+ # presence of the key and if its available we return it
0
+ if object.respond_to?(:[]) and
0
+ ((object.respond_to?(:has_key?) and object.has_key?(part)) or
0
+ (object.respond_to?(:fetch) and part.is_a?(Integer)))
0
- if part =~ square_bracketed
0
+ # if its a proc we will replace the entry with the proc
0
+ res = object[part] = res.call(self) if res.is_a?(Proc) and object.respond_to?(:[]=)
0
+ object = res.to_liquid
0
- object[pos] = object[part].call(self) if object[part].is_a?(Proc) and object.respond_to?(:[]=)
0
- object = object[part].to_liquid
0
+ # Some special cases. If the part wasn't in square brackets and
0
+ # no key with the same name was found we interpret following calls
0
+ # as commands and call them on the current object
0
+ elsif !part_resolved and object.respond_to?(part) and ['size', 'first', 'last'].include?(part)
0
- if object.respond_to?(:has_key?) and object.has_key?(part)
0
- # if its a proc we will replace the entry in the hash table with the proc
0
- res = object[part] = res.call(self) if res.is_a?(Proc) and object.respond_to?(:[]=)
0
- object = res.to_liquid
0
- elsif object.respond_to?(:fetch) and part =~ /^\d+$/
0
- object[pos] = object[pos].call(self) if object[pos].is_a?(Proc) and object.respond_to?(:[]=)
0
- object = object[pos].to_liquid
0
- # Some special cases. If no key with the same name was found we interpret following calls
0
- # as commands and call them on the current object
0
- elsif object.respond_to?(part) and ['size', 'first', 'last'].include?(part)
0
+ object = object.send(part.intern).to_liquid
0
- object = object.send(part.intern).to_liquid
0
- # No key was present with the desired value and it wasn't one of the directly supported
0
- # keywords either. The only thing we got left is to return nil
0
+ # No key was present with the desired value and it wasn't one of the directly supported
0
+ # keywords either. The only thing we got left is to return nil
0
# If we are dealing with a drop here we have to
0
@@ -235,11 +221,5 @@ module Liquid
0
- def execute_proc(proc)