Raise SyntaxError if raw tag is unclosed

This commit is contained in:
Justin Li 2015-06-02 10:56:51 -04:00
parent be2e41e4d5
commit b1ee9129e7
3 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,8 @@ module Liquid
end
@body << token unless token.empty?
end
raise SyntaxError.new(@options[:locale].t("errors.syntax.tag_never_closed".freeze, block_name: block_name))
end
def render(_context)

View File

@ -22,4 +22,8 @@ class RawTagTest < Minitest::Test
assert_template_result ' test {% raw %} {% endraw %}', '{% raw %} test {% raw %} {% {% endraw %}endraw %}'
assert_template_result ' Foobar {{ invalid 1', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}'
end
def test_invalid_raw
assert_match_syntax_error /tag was never closed/, '{% raw } foo {% endraw %}'
end
end

View File

@ -42,7 +42,7 @@ module Minitest
assert_match expected, Template.parse(template).render!(assigns), message
end
def assert_match_syntax_error(match, template, registers = {})
def assert_match_syntax_error(match, template, assigns = {})
exception = assert_raises(Liquid::SyntaxError) {
Template.parse(template).render(assigns)
}