mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 10:15:40 +03:00
Compare commits
11 Commits
v3.0.2
...
3-0-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d19fdde7f | ||
|
|
e934826820 | ||
|
|
529cc60ef1 | ||
|
|
5068fcae03 | ||
|
|
4095bfa9f8 | ||
|
|
0148289b88 | ||
|
|
d891c2b7ab | ||
|
|
ebbfb54de4 | ||
|
|
8f84ddb5ce | ||
|
|
09de50dcb1 | ||
|
|
49f2af4209 |
24
History.md
24
History.md
@@ -1,6 +1,18 @@
|
|||||||
# Liquid Version History
|
# Liquid Version History
|
||||||
|
|
||||||
## 3.0.2 / 2015-04-24 / branch "3-0-stable"
|
## 3.0.5 / 2015-07-23 / branch "3-0-stable"
|
||||||
|
|
||||||
|
* Fix test failure under certain timezones [Dylan Thacker-Smith]
|
||||||
|
|
||||||
|
## 3.0.4 / 2015-07-17
|
||||||
|
|
||||||
|
* Fix chained access to multi-dimensional hashes [Florian Weingarten]
|
||||||
|
|
||||||
|
## 3.0.3 / 2015-05-28
|
||||||
|
|
||||||
|
* Fix condition parse order in strict mode (#569) [Justin Li, pushrax]
|
||||||
|
|
||||||
|
## 3.0.2 / 2015-04-24
|
||||||
|
|
||||||
* Expose VariableLookup private members (#551) [Justin Li, pushrax]
|
* Expose VariableLookup private members (#551) [Justin Li, pushrax]
|
||||||
* Documentation fixes
|
* Documentation fixes
|
||||||
@@ -44,7 +56,15 @@
|
|||||||
* Make map filter work on enumerable drops, see #233 [Florian Weingarten, fw42]
|
* Make map filter work on enumerable drops, see #233 [Florian Weingarten, fw42]
|
||||||
* Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten, fw42]
|
* Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten, fw42]
|
||||||
|
|
||||||
## 2.6.1 / 2014-01-10 / branch "2-6-stable"
|
## 2.6.3 / 2015-07-23 / branch "2-6-stable"
|
||||||
|
|
||||||
|
* Fix test failure under certain timezones [Dylan Thacker-Smith]
|
||||||
|
|
||||||
|
## 2.6.2 / 2015-01-23
|
||||||
|
|
||||||
|
* Remove duplicate hash key [Parker Moore]
|
||||||
|
|
||||||
|
## 2.6.1 / 2014-01-10
|
||||||
|
|
||||||
Security fix, cherry-picked from master (4e14a65):
|
Security fix, cherry-picked from master (4e14a65):
|
||||||
* Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
|
* Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ module Liquid
|
|||||||
|
|
||||||
def variable_signature
|
def variable_signature
|
||||||
str = consume(:id)
|
str = consume(:id)
|
||||||
if look(:open_square)
|
while look(:open_square)
|
||||||
str << consume
|
str << consume
|
||||||
str << expression
|
str << expression
|
||||||
str << consume(:close_square)
|
str << consume(:close_square)
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ module Liquid
|
|||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
rescue ArgumentError
|
rescue ::ArgumentError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -78,16 +78,16 @@ module Liquid
|
|||||||
|
|
||||||
def strict_parse(markup)
|
def strict_parse(markup)
|
||||||
p = Parser.new(markup)
|
p = Parser.new(markup)
|
||||||
|
condition = parse_binary_comparison(p)
|
||||||
condition = parse_comparison(p)
|
|
||||||
|
|
||||||
while op = (p.id?('and'.freeze) || p.id?('or'.freeze))
|
|
||||||
new_cond = parse_comparison(p)
|
|
||||||
new_cond.send(op, condition)
|
|
||||||
condition = new_cond
|
|
||||||
end
|
|
||||||
p.consume(:end_of_string)
|
p.consume(:end_of_string)
|
||||||
|
condition
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_binary_comparison(p)
|
||||||
|
condition = parse_comparison(p)
|
||||||
|
if op = (p.id?('and'.freeze) || p.id?('or'.freeze))
|
||||||
|
condition.send(op, parse_binary_comparison(p))
|
||||||
|
end
|
||||||
condition
|
condition
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
module Liquid
|
module Liquid
|
||||||
VERSION = "3.0.2"
|
VERSION = "3.0.6"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ class OutputTest < Minitest::Test
|
|||||||
assert_equal expected, Template.parse(text).render!(@assigns)
|
assert_equal expected, Template.parse(text).render!(@assigns)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_variable_traversing_with_two_brackets
|
||||||
|
text = %({{ site.data.menu[include.menu][include.locale] }})
|
||||||
|
assert_equal "it works!", Template.parse(text).render!(
|
||||||
|
"site" => { "data" => { "menu" => { "foo" => { "bar" => "it works!" } } } },
|
||||||
|
"include" => { "menu" => "foo", "locale" => "bar" }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def test_variable_traversing
|
def test_variable_traversing
|
||||||
text = %| {{car.bmw}} {{car.gm}} {{car.bmw}} |
|
text = %| {{car.bmw}} {{car.gm}} {{car.bmw}} |
|
||||||
|
|
||||||
|
|||||||
@@ -252,8 +252,10 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
|
|
||||||
assert_equal nil, @filters.date(nil, "%B")
|
assert_equal nil, @filters.date(nil, "%B")
|
||||||
|
|
||||||
assert_equal "07/05/2006", @filters.date(1152098955, "%m/%d/%Y")
|
with_timezone("UTC") do
|
||||||
assert_equal "07/05/2006", @filters.date("1152098955", "%m/%d/%Y")
|
assert_equal "07/05/2006", @filters.date(1152098955, "%m/%d/%Y")
|
||||||
|
assert_equal "07/05/2006", @filters.date("1152098955", "%m/%d/%Y")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_first_last
|
def test_first_last
|
||||||
@@ -376,4 +378,19 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
def test_cannot_access_private_methods
|
def test_cannot_access_private_methods
|
||||||
assert_template_result('a',"{{ 'a' | to_number }}")
|
assert_template_result('a',"{{ 'a' | to_number }}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_date_raises_nothing
|
||||||
|
assert_template_result('', "{{ '' | date: '%D' }}")
|
||||||
|
assert_template_result('abc', "{{ 'abc' | date: '%D' }}")
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def with_timezone(tz)
|
||||||
|
old_tz = ENV['TZ']
|
||||||
|
ENV['TZ'] = tz
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
ENV['TZ'] = old_tz
|
||||||
|
end
|
||||||
end # StandardFiltersTest
|
end # StandardFiltersTest
|
||||||
|
|||||||
@@ -166,4 +166,25 @@ class IfElseTagTest < Minitest::Test
|
|||||||
assert_template_result('', %({% if 1 or throw or or 1 %}yes{% endif %}))
|
assert_template_result('', %({% if 1 or throw or or 1 %}yes{% endif %}))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_multiple_conditions
|
||||||
|
tpl = "{% if a or b and c %}true{% else %}false{% endif %}"
|
||||||
|
|
||||||
|
tests = {
|
||||||
|
[true, true, true] => true,
|
||||||
|
[true, true, false] => true,
|
||||||
|
[true, false, true] => true,
|
||||||
|
[true, false, false] => true,
|
||||||
|
[false, true, true] => true,
|
||||||
|
[false, true, false] => false,
|
||||||
|
[false, false, true] => false,
|
||||||
|
[false, false, false] => false,
|
||||||
|
}
|
||||||
|
|
||||||
|
tests.each do |vals, expected|
|
||||||
|
a, b, c = vals
|
||||||
|
assigns = { 'a' => a, 'b' => b, 'c' => c }
|
||||||
|
assert_template_result expected.to_s, tpl, assigns, assigns.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ module Minitest
|
|||||||
include Liquid
|
include Liquid
|
||||||
|
|
||||||
def assert_template_result(expected, template, assigns = {}, message = nil)
|
def assert_template_result(expected, template, assigns = {}, message = nil)
|
||||||
assert_equal expected, Template.parse(template).render!(assigns)
|
assert_equal expected, Template.parse(template).render!(assigns), message
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_template_result_matches(expected, template, assigns = {}, message = nil)
|
def assert_template_result_matches(expected, template, assigns = {}, message = nil)
|
||||||
return assert_template_result(expected, template, assigns, message) unless expected.is_a? Regexp
|
return assert_template_result(expected, template, assigns, message) unless expected.is_a? Regexp
|
||||||
|
|
||||||
assert_match expected, Template.parse(template).render!(assigns)
|
assert_match expected, Template.parse(template).render!(assigns), message
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_match_syntax_error(match, template, registers = {})
|
def assert_match_syntax_error(match, template, registers = {})
|
||||||
|
|||||||
Reference in New Issue
Block a user