mirror of
https://github.com/kemko/liquid.git
synced 2026-01-05 17:55:40 +03:00
Allow variable and tag end characters to be quoted.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
13
test/integration/tags/assign_tag_test.rb
Normal file
13
test/integration/tags/assign_tag_test.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user