diff --git a/lib/liquid.rb b/lib/liquid.rb index f4c6fea..dd33dce 100644 --- a/lib/liquid.rb +++ b/lib/liquid.rb @@ -35,7 +35,8 @@ module Liquid QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o AnyStartingTag = /\{\{|\{\%/ - PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om + tag_contents = /(?:#{QuotedString}|.)*?/m + PartialTemplateParser = /#{TagStart}#{tag_contents}#{TagEnd}|#{VariableStart}#{tag_contents}#{VariableIncompleteEnd}/om TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o diff --git a/test/integration/tags/assign_tag_test.rb b/test/integration/tags/assign_tag_test.rb new file mode 100644 index 0000000..9796daf --- /dev/null +++ b/test/integration/tags/assign_tag_test.rb @@ -0,0 +1,13 @@ +require 'test_helper' + +class AssignTagTest < Minitest::Test + include Liquid + + def test_assign + assert_template_result('monkey', "{% assign foo = 'monkey' %}{{ foo }}") + end + + def test_string_with_end_tag + assert_template_result("{% quoted %}", "{% assign string = '{% quoted %}' %}{{ string }}") + end +end diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index 58df833..cf4cf94 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -89,4 +89,9 @@ class VariableTest < Minitest::Test def test_multiline_variable assert_equal 'worked', Template.parse("{{\ntest\n}}").render!('test' => 'worked') end + + def test_string_with_curly_brackets + json = '{ "key": { "nested": "value" }}' + assert_template_result(json, "{{ '#{json}' }}") + end end