Merge pull request #306 from Shopify/default_to_s_for_drops

Liquid::Drop should not return a string representation of standard ruby objects
This commit is contained in:
Adam Doeler
2014-02-13 13:45:01 -05:00
3 changed files with 10 additions and 0 deletions

View File

@@ -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]

View File

@@ -52,6 +52,10 @@ module Liquid
self
end
def to_s
self.class.name
end
alias :[] :invoke_drop
private

View File

@@ -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