Allow a Liquid::Drop to be passed into Template#render

This commit is contained in:
Daniel Huckstep
2013-06-06 10:17:01 -06:00
parent 85c1503378
commit b699c93bae
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -93,6 +93,8 @@ module Liquid
context = case args.first
when Liquid::Context
args.shift
when 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)
when nil
+17
View File
@@ -1,5 +1,15 @@
require 'test_helper'
class TemplateContextDrop < Liquid::Drop
def before_method(method)
method
end
def foo
'foo'
end
end
class TemplateTest < Test::Unit::TestCase
include Liquid
@@ -120,4 +130,11 @@ class TemplateTest < Test::Unit::TestCase
assert t.resource_limits[:render_score_current] > 0
assert t.resource_limits[:render_length_current] > 0
end
def test_can_use_drop_as_context
t = Template.new
drop = TemplateContextDrop.new
assert_equal 'foo', t.parse('{{foo}}').render(drop)
assert_equal 'bar', t.parse('{{bar}}').render(drop)
end
end # TemplateTest