From 5f8a028a56de4c9d69c9cf4eb32a29fe494f7827 Mon Sep 17 00:00:00 2001 From: Adam Doeler Date: Fri, 7 Feb 2014 14:48:02 -0500 Subject: [PATCH 1/2] Liquid::Drop should not return a string representation of standard ruby objects --- lib/liquid/drop.rb | 4 ++++ test/liquid/drop_test.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/liquid/drop.rb b/lib/liquid/drop.rb index d4e5941..e4880c4 100644 --- a/lib/liquid/drop.rb +++ b/lib/liquid/drop.rb @@ -52,6 +52,10 @@ module Liquid self end + def to_s + self.class.name + end + alias :[] :invoke_drop private diff --git a/test/liquid/drop_test.rb b/test/liquid/drop_test.rb index d8d02d9..ab828d8 100644 --- a/test/liquid/drop_test.rb +++ b/test/liquid/drop_test.rb @@ -237,4 +237,9 @@ class DropsTest < Test::Unit::TestCase def test_nil_value_access assert_equal '', Liquid::Template.parse('{{ product[value] }}').render('product' => ProductDrop.new, 'value' => nil) end + + def test_default_to_s_on_drops + assert_equal 'ProductDrop', Liquid::Template.parse("{{ product }}").render('product' => ProductDrop.new) + assert_equal 'EnumerableDrop', Liquid::Template.parse('{{ collection }}').render('collection' => EnumerableDrop.new) + end end # DropsTest From 18907fc5707b38f1520f8599b3e9d6bbc8feb812 Mon Sep 17 00:00:00 2001 From: Adam Doeler Date: Mon, 10 Feb 2014 10:24:37 -0500 Subject: [PATCH 2/2] Updates History.md --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index b57c71a..c097a1f 100644 --- a/History.md +++ b/History.md @@ -3,6 +3,7 @@ ## 3.0.0 / not yet released / branch "master" * ... +* Add a to_s default for liquid drops, see #306 [Adam Doeler, releod] * Add strip, lstrip, and rstrip to standard filters [Florian Weingarten, fw42] * Make if, for & case tags return complete and consistent nodelists, see #250 [Nick Jones, dntj] * Prevent arbitrary method invocation on condition objects, see #274 [Dylan Thacker-Smith, dylanahsmith]