mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-04 01:25:14 -07:00
Better test, resuse Hash block
This commit is contained in:
@@ -93,9 +93,7 @@ module Liquid
|
|||||||
context = case args.first
|
context = case args.first
|
||||||
when Liquid::Context
|
when Liquid::Context
|
||||||
args.shift
|
args.shift
|
||||||
when Liquid::Drop
|
when Hash, Liquid::Drop
|
||||||
Context.new(args.shift, instance_assigns, registers, @rethrow_errors)
|
|
||||||
when Hash
|
|
||||||
Context.new([args.shift, assigns], instance_assigns, registers, @rethrow_errors, @resource_limits)
|
Context.new([args.shift, assigns], instance_assigns, registers, @rethrow_errors, @resource_limits)
|
||||||
when nil
|
when nil
|
||||||
Context.new(assigns, instance_assigns, registers, @rethrow_errors, @resource_limits)
|
Context.new(assigns, instance_assigns, registers, @rethrow_errors, @resource_limits)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class TemplateContextDrop < Liquid::Drop
|
|||||||
end
|
end
|
||||||
|
|
||||||
def foo
|
def foo
|
||||||
'foo'
|
'fizzbuzz'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ class TemplateTest < Test::Unit::TestCase
|
|||||||
def test_can_use_drop_as_context
|
def test_can_use_drop_as_context
|
||||||
t = Template.new
|
t = Template.new
|
||||||
drop = TemplateContextDrop.new
|
drop = TemplateContextDrop.new
|
||||||
assert_equal 'foo', t.parse('{{foo}}').render(drop)
|
assert_equal 'fizzbuzz', t.parse('{{foo}}').render(drop)
|
||||||
assert_equal 'bar', t.parse('{{bar}}').render(drop)
|
assert_equal 'bar', t.parse('{{bar}}').render(drop)
|
||||||
end
|
end
|
||||||
end # TemplateTest
|
end # TemplateTest
|
||||||
|
|||||||
Reference in New Issue
Block a user