diff --git a/lib/liquid.rb b/lib/liquid.rb index 12b8f23..12c9c8a 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -35,7 +35,9 @@ module Liquid VariableIncompleteEnd = /\}\}?/ QuotedFragment = /"[^"]+"|'[^']+'|[^\s,|]+/ TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/ - TemplateParser = /(#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd})/ + AnyStartingTag = /\{\{|\{\%/ + PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/ + TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/ VariableParser = /\[[^\]]+\]|#{VariableSegment}+/ end diff --git a/test/parsing_quirks_test.rb b/test/parsing_quirks_test.rb index e9e2b21..5cebd52 100644 --- a/test/parsing_quirks_test.rb +++ b/test/parsing_quirks_test.rb @@ -18,6 +18,17 @@ class ParsingQuirksTest < Test::Unit::TestCase end end + def test_raise_on_label_and_no_close_bracets + assert_raise(SyntaxError) do + Template.parse("TEST {{ ") + end + end + + def test_raise_on_label_and_no_close_bracets_percent + assert_raise(SyntaxError) do + Template.parse("TEST {% ") + end + end def test_error_on_empty_filter assert_nothing_raised do @@ -26,4 +37,5 @@ class ParsingQuirksTest < Test::Unit::TestCase Template.parse("{{|test|}}") end end + end \ No newline at end of file