Initial concept

This commit is contained in:
Mike Angell
2019-09-20 15:35:12 +10:00
parent f4d134cd5c
commit 3ffae9a6e4
7 changed files with 190 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
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
def test_liquid_issue_701
assert_template_result(" contents: _{% endraw %}_", "{% assign endraw = '{% endraw %}' %} contents: _{{endraw}}_")
end
end
+7 -1
View File
@@ -23,11 +23,17 @@ class RawTagTest < Minitest::Test
assert_template_result ' Foobar {% {% {% ', '{% raw %} Foobar {% {% {% {% endraw %}'
assert_template_result ' test {% raw %} {% endraw %}', '{% raw %} test {% raw %} {% {% endraw %}endraw %}'
assert_template_result ' Foobar {{ invalid 1', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}'
assert_template_result ' Foobar {{ invalid 12', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}{{ 2 }}'
assert_template_result ' Foobar {{ invalid 1', '{% raw %} Foobar {{ invalid {% endraw %}{{ 1 }}'
end
def test_nested_tag_in_raw
assert_template_result '{{ {% test %} }}', '{% raw %}{{ {% test %} }}{% endraw %}'
end
def test_invalid_raw
assert_match_syntax_error(/tag was never closed/, '{% raw %} foo')
assert_match_syntax_error(/Valid syntax/, '{% raw } foo {% endraw %}')
assert_match_syntax_error(/was not properly terminated/, '{% raw } foo {% endraw %}')
assert_match_syntax_error(/Valid syntax/, '{% raw } foo %}{% endraw %}')
end
end
+5
View File
@@ -361,4 +361,9 @@ class TemplateTest < Minitest::Test
result = t.render('x' => 1, 'y' => 5)
assert_equal '12345', result
end
def test_curly_braces
assert_template_result "{}", "{{ '{}' }}"
assert_template_result "{}", "{% assign test = '{}' %}{{ test }}"
end
end
+17
View File
@@ -95,4 +95,21 @@ class VariableTest < Minitest::Test
def test_render_symbol
assert_template_result 'bar', '{{ foo }}', 'foo' => :bar
end
def test_quoted_single_curly_braces
assert_template_result "{user}", "{{ variable | prepend: '{' | append: '}' }}", 'variable' => 'user'
end
def test_string_with_curly_brackets
json = '{ "key": { "nested": "value" }}'
assert_template_result(json, "{{ '#{json}' }}")
end
def test_liquid_issue_344
assert_template_result "blah xx yy }}", "{{ 'blah {{ yy }}' | replace: '{{', 'xx' }}"
end
def test_liquid_issue_213
assert_template_result "blah", "{{ 'blah}' | remove: '}' }}"
end
end