diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index 73ffca0..9ff7260 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -105,7 +105,7 @@ module Liquid end def invoke(method, *args) - strainer.invoke(method, *args) + strainer.invoke(method, *args).to_liquid end # Push new local scope on the stack. use Context#stack instead diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index ffa2ebb..7e2cc6d 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -220,6 +220,11 @@ class StandardFiltersTest < Minitest::Test assert_template_result "213", '{{ foo | sort: "bar" | map: "foo" }}', "foo" => TestEnumerable.new end + def test_first_and_last_call_to_liquid + assert_template_result 'foobar', '{{ foo | first }}', 'foo' => [ThingWithToLiquid.new] + assert_template_result 'foobar', '{{ foo | last }}', 'foo' => [ThingWithToLiquid.new] + end + def test_date assert_equal 'May', @filters.date(Time.parse("2006-05-05 10:00:00"), "%B") assert_equal 'June', @filters.date(Time.parse("2006-06-05 10:00:00"), "%B") diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index 37456cc..bd98131 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -9,6 +9,10 @@ class VariableTest < Minitest::Test assert_equal 'worked wonderfully', template.render!('test' => 'worked wonderfully') end + def test_variable_render_calls_to_liquid + assert_template_result 'foobar', '{{ foo }}', 'foo' => ThingWithToLiquid.new + end + def test_simple_with_whitespaces template = Template.parse(%| {{ test }} |) assert_equal ' worked ', template.render!('test' => 'worked') diff --git a/test/test_helper.rb b/test/test_helper.rb index d513f65..9c0daa9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -66,3 +66,9 @@ module Minitest end end end + +class ThingWithToLiquid + def to_liquid + 'foobar' + end +end