mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 17:30:43 -07:00
allow nil template source
This commit is contained in:
@@ -108,7 +108,7 @@ module Liquid
|
||||
def parse(source, 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")
|
||||
end
|
||||
|
||||
|
||||
@@ -349,4 +349,9 @@ class TemplateTest < Minitest::Test
|
||||
|
||||
assert_equal('Liquid syntax error: Invalid template encoding', e.message)
|
||||
end
|
||||
|
||||
def test_allows_nil_as_source
|
||||
template = Template.parse(nil)
|
||||
assert_equal('', template.render)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user