From 8b5cf73ccc608060c32c5c87f6541df67ce6b405 Mon Sep 17 00:00:00 2001 From: Jonathan Rudenberg Date: Thu, 13 Oct 2011 11:25:35 -0400 Subject: [PATCH] Fix regression with calling a drop with a empty string --- lib/liquid/drop.rb | 2 +- test/lib/liquid/drop_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/liquid/drop.rb b/lib/liquid/drop.rb index db507eb..ccb4d3c 100644 --- a/lib/liquid/drop.rb +++ b/lib/liquid/drop.rb @@ -29,7 +29,7 @@ module Liquid # called by liquid to invoke a drop def invoke_drop(method_or_key) - if self.class.public_method_defined?(method_or_key.to_s.to_sym) + if method_or_key != '' && self.class.public_method_defined?(method_or_key.to_s.to_sym) send(method_or_key.to_s.to_sym) else before_method(method_or_key) diff --git a/test/lib/liquid/drop_test.rb b/test/lib/liquid/drop_test.rb index 4d74a1d..e5b2d81 100644 --- a/test/lib/liquid/drop_test.rb +++ b/test/lib/liquid/drop_test.rb @@ -155,4 +155,8 @@ class DropsTest < Test::Unit::TestCase def test_enumerable_drop_size assert_equal '3', Liquid::Template.parse( '{{collection.size}}').render('collection' => EnumerableDrop.new) end + + def test_empty_string_value_access + assert_equal '', Liquid::Template.parse('{{ product[value] }}').render('product' => ProductDrop.new, 'value' => '') + end end # DropsTest