mirror of
https://github.com/kemko/liquid.git
synced 2026-01-03 16:55:40 +03:00
Literal
- added support for literals [closes #6] Code beautifier - indented some files
This commit is contained in:
@@ -41,4 +41,8 @@ class RegexpTest < Test::Unit::TestCase
|
||||
assert_equal ['var', '["method"]', '[0]'], 'var["method"][0]'.scan(VariableParser)
|
||||
assert_equal ['var', '[method]', '[0]', 'method'], 'var[method][0].method'.scan(VariableParser)
|
||||
end
|
||||
|
||||
def test_literal_shorthand_regexp
|
||||
assert_match "{{{ {% if 'gnomeslab' contains 'liquid' %}yes{% endif %} }}}", LiteralShorthand
|
||||
end
|
||||
end # RegexpTest
|
||||
|
||||
39
test/lib/liquid/tags/literal_test.rb
Normal file
39
test/lib/liquid/tags/literal_test.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LiteralTagTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
def test_empty_literal
|
||||
assert_template_result '', '{% literal %}{% endliteral %}'
|
||||
assert_template_result '', '{{{}}}'
|
||||
end
|
||||
|
||||
def test_simple_literal_value
|
||||
assert_template_result 'howdy',
|
||||
'{% literal %}howdy{% endliteral %}'
|
||||
end
|
||||
|
||||
def test_literals_ignore_liquid_markup
|
||||
expected = %({% if 'gnomeslab' contain 'liquid' %}yes{ % endif %})
|
||||
template = %({% literal %}#{expected}{% endliteral %})
|
||||
|
||||
assert_template_result expected, template
|
||||
end
|
||||
|
||||
def test_shorthand_syntax
|
||||
expected = %({% if 'gnomeslab' contain 'liquid' %}yes{ % endif %})
|
||||
template = %({{{#{expected}}}})
|
||||
|
||||
assert_template_result expected, template
|
||||
end
|
||||
|
||||
# Class methods
|
||||
def test_from_shorthand
|
||||
assert_equal '{% literal %}gnomeslab{% endliteral %}', Liquid::Literal.from_shorthand('{{{gnomeslab}}}')
|
||||
end
|
||||
|
||||
def test_from_shorthand_ignores_improper_syntax
|
||||
text = "{% if 'hi' == 'hi' %}hi{% endif %}"
|
||||
assert_equal text, Liquid::Literal.from_shorthand(text)
|
||||
end
|
||||
end # AssignTest
|
||||
Reference in New Issue
Block a user