Compare commits

...

2 Commits

Author SHA1 Message Date
Dylan Thacker-Smith
6a9a7ae8d2 Use tokenizer-quoted-strings liquid-c branch. 2015-07-13 22:03:16 -04:00
Dylan Thacker-Smith
4a12fee1f5 Allow variable and tag end characters to be quoted. 2015-07-13 13:19:56 -04:00
4 changed files with 21 additions and 2 deletions

View File

@@ -9,6 +9,6 @@ group :test do
gem 'rubocop', '>=0.32.0'
platform :mri do
gem 'liquid-c', github: 'Shopify/liquid-c', ref: '2570693d8d03faa0df9160ec74348a7149436df3'
gem 'liquid-c', github: 'Shopify/liquid-c', ref: '11d38237d9f491588a58c83dc3d364a7d0d1d55b'
end
end

View File

@@ -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

View File

@@ -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

View File

@@ -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