mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 18:25:41 +03:00
Merge pull request #414 from Shopify/to_liquid_context
Call to_liquid in Context invoke
This commit is contained in:
@@ -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 <tt>Context#stack</tt> instead
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -66,3 +66,9 @@ module Minitest
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ThingWithToLiquid
|
||||
def to_liquid
|
||||
'foobar'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user