allow nil template source

This commit is contained in:
Michael Go
2024-01-10 16:32:08 -04:00
parent 3ac7e470e6
commit 730ad3684a
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -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
+5
View File
@@ -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