mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
allow nil template source
This commit is contained in:
@@ -108,7 +108,7 @@ module Liquid
|
|||||||
def parse(source, options = {})
|
def parse(source, options = {})
|
||||||
parse_context = configure_options(options)
|
parse_context = configure_options(options)
|
||||||
|
|
||||||
unless source.valid_encoding?
|
if source.is_a?(String) && !source.valid_encoding?
|
||||||
raise SyntaxError, parse_context.locale.t("errors.syntax.invalid_template_encoding")
|
raise SyntaxError, parse_context.locale.t("errors.syntax.invalid_template_encoding")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -349,4 +349,9 @@ class TemplateTest < Minitest::Test
|
|||||||
|
|
||||||
assert_equal('Liquid syntax error: Invalid template encoding', e.message)
|
assert_equal('Liquid syntax error: Invalid template encoding', e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_allows_nil_as_source
|
||||||
|
template = Template.parse(nil)
|
||||||
|
assert_equal('', template.render)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user