mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
Fix Liquid::Template inheritance (#1227)
self.class.default_resource_limits would return `nil` in a subclass, since the attribute isn't set on subclasses.
This commit is contained in:
@@ -119,14 +119,13 @@ module Liquid
|
|||||||
# To enable profiling, pass in <tt>profile: true</tt> as an option.
|
# To enable profiling, pass in <tt>profile: true</tt> as an option.
|
||||||
# See Liquid::Profiler for more information
|
# See Liquid::Profiler for more information
|
||||||
def parse(source, options = {})
|
def parse(source, options = {})
|
||||||
template = Template.new
|
new.parse(source, options)
|
||||||
template.parse(source, options)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@rethrow_errors = false
|
@rethrow_errors = false
|
||||||
@resource_limits = ResourceLimits.new(self.class.default_resource_limits)
|
@resource_limits = ResourceLimits.new(Template.default_resource_limits)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parse source code.
|
# Parse source code.
|
||||||
|
|||||||
@@ -77,4 +77,11 @@ class TemplateUnitTest < Minitest::Test
|
|||||||
ensure
|
ensure
|
||||||
Template.tags.delete('fake')
|
Template.tags.delete('fake')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TemplateSubclass < Liquid::Template
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_template_inheritance
|
||||||
|
assert_equal("foo", TemplateSubclass.parse("foo").render)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user