mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 16:25:42 +03:00
Compare commits
2 Commits
render-for
...
tokenizer-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a9a7ae8d2 | ||
|
|
4a12fee1f5 |
2
Gemfile
2
Gemfile
@@ -9,6 +9,6 @@ group :test do
|
|||||||
gem 'rubocop', '>=0.32.0'
|
gem 'rubocop', '>=0.32.0'
|
||||||
|
|
||||||
platform :mri do
|
platform :mri do
|
||||||
gem 'liquid-c', github: 'Shopify/liquid-c', ref: '2570693d8d03faa0df9160ec74348a7149436df3'
|
gem 'liquid-c', github: 'Shopify/liquid-c', ref: '11d38237d9f491588a58c83dc3d364a7d0d1d55b'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ module Liquid
|
|||||||
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
||||||
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o
|
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o
|
||||||
AnyStartingTag = /\{\{|\{\%/
|
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
|
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om
|
||||||
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o
|
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
|
def test_multiline_variable
|
||||||
assert_equal 'worked', Template.parse("{{\ntest\n}}").render!('test' => 'worked')
|
assert_equal 'worked', Template.parse("{{\ntest\n}}").render!('test' => 'worked')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_string_with_curly_brackets
|
||||||
|
json = '{ "key": { "nested": "value" }}'
|
||||||
|
assert_template_result(json, "{{ '#{json}' }}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user