mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Reverted james filter in tags branch
This reverts commit 282786d7e2.
Conflicts:
lib/liquid.rb
lib/liquid/variable.rb
test/if_else_test.rb
This commit is contained in:
+3
-4
@@ -1,11 +1,10 @@
|
||||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
class IfElseTest < Test::Unit::TestCase
|
||||
class AssignTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
def test_with_filtered_expressions
|
||||
assert_template_result('foo','{% assign foo = values|sort|last %}{{ foo }}', 'values' => %w{foo bar baz})
|
||||
assert_template_result('foo','{% assign sorted = values|sort %}{{ sorted | last }}', 'values' => %w{foo bar baz})
|
||||
def test_assigned_variable
|
||||
assert_template_result('.foo.','{% assign foo = values %}.{{ foo }}.', 'values' => %w{foo bar baz})
|
||||
end
|
||||
|
||||
end
|
||||
@@ -112,25 +112,6 @@ class IfElseTest < Test::Unit::TestCase
|
||||
assert_template_result('elsif','{% if false %}if{% elsif true %}elsif{% endif %}')
|
||||
end
|
||||
|
||||
def test_with_filtered_expressions
|
||||
assert_template_result('yes','{% if "BLAH"|downcase == "blah" %}yes{% endif %}')
|
||||
assert_template_result('yes','{% if "FOO BAR"|truncatewords:1,"--" == "FOO--" %}yes{% endif %}')
|
||||
assert_template_result('yes','{% if "FOO BAR"|truncatewords:1,"--"|downcase == "foo--" %}yes{% endif %}')
|
||||
assert_template_result('yes','{% if "foo--" == "FOO BAR"|truncatewords:1,"--"|downcase %}yes{% endif %}')
|
||||
# array transformation, to make sure we aren't converting arrays to strings somewhere along the way:
|
||||
assert_template_result('yes','{% if values|sort == sorted %}yes{% endif %}', 'values' => %w{foo bar baz}, 'sorted' => %w{bar baz foo})
|
||||
end
|
||||
|
||||
def test_allow_no_spaces_in_filtered_expressions
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR" |truncatewords:1,"--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"| truncatewords:1,"--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"|truncatewords :1,"--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"|truncatewords: 1,"--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"|truncatewords:1 ,"--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"|truncatewords:1, "--"|downcase %}yes{% endif %}')
|
||||
assert_template_result('','{% if "foo--" == "FOO BAR"|truncatewords:1,"--" |downcase %}yes{% endif %}')
|
||||
end
|
||||
|
||||
def test_syntax_error_no_variable
|
||||
assert_raise(SyntaxError){ assert_template_result('', '{% if jerry == 1 %}')}
|
||||
end
|
||||
|
||||
@@ -98,11 +98,7 @@ HERE
|
||||
assigns = {'array' => [1,2,3] }
|
||||
assert_template_result('+--', '{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}', assigns)
|
||||
end
|
||||
|
||||
def test_for_with_filtered_expressions
|
||||
assert_template_result('abc','{% for letter in letters|sort %}{{ letter }}{% endfor %}', 'letters' => %w{c b a})
|
||||
end
|
||||
|
||||
|
||||
def test_limiting
|
||||
assigns = {'array' => [1,2,3,4,5,6,7,8,9,0]}
|
||||
assert_template_result('12','{%for i in array limit:2 %}{{ i }}{%endfor%}',assigns)
|
||||
@@ -353,10 +349,10 @@ HERE
|
||||
|
||||
assert_template_result('one two one','{%cycle "one", "two"%} {%cycle "one", "two"%} {%cycle "one", "two"%}')
|
||||
|
||||
assert_template_result('text-align: left text-align: right','{%cycle "text-align: left", "text-align: right" %} {%cycle "text-align: left", "text-align: right"%}')
|
||||
assert_template_result('text-align: left,text-align: right','{%cycle "text-align: left", "text-align: right" %},{%cycle "text-align: left", "text-align: right"%}')
|
||||
|
||||
assert_template_result(' ','{% cycle "", "", "</tr><tr>" %}')
|
||||
assert_template_result(' </tr><tr> ','{% cycle "", "", "</tr><tr>" %} {% cycle "", "", "</tr><tr>" %} {% cycle "", "", "</tr><tr>" %} {% cycle "", "", "</tr><tr>" %}')
|
||||
assert_template_result('.','.{% cycle "", "", "</tr><tr>" %}')
|
||||
assert_template_result('...</tr><tr> ','.{% cycle "", "", "</tr><tr>" %}.{% cycle "", "", "</tr><tr>" %}.{% cycle "", "", "</tr><tr>" %} {% cycle "", "", "</tr><tr>" %}')
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user