Skip to content

Commit

Permalink
allow nil template source
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmichaelgo committed Jan 10, 2024
1 parent 3ac7e47 commit 730ad36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/liquid/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def initialize
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

Expand Down
5 changes: 5 additions & 0 deletions test/integration/template_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,9 @@ def test_raises_error_with_invalid_utf8

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

0 comments on commit 730ad36

Please sign in to comment.