From c8906d05b928cd9ceaa38e8ca439bba8cbb9b5a6 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Thu, 9 Sep 2021 11:17:25 -0400 Subject: [PATCH 1/6] Add ParseTreeVisitor to RangeLookup --- lib/liquid/range_lookup.rb | 8 ++++++++ test/unit/parse_tree_visitor_test.rb | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/lib/liquid/range_lookup.rb b/lib/liquid/range_lookup.rb index 57bccd00..7e159be6 100644 --- a/lib/liquid/range_lookup.rb +++ b/lib/liquid/range_lookup.rb @@ -12,6 +12,8 @@ module Liquid end end + attr_reader :start_obj, :end_obj + def initialize(start_obj, end_obj) @start_obj = start_obj @end_obj = end_obj @@ -35,5 +37,11 @@ module Liquid Utils.to_integer(input) end end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.start_obj, @node.end_obj] + end + end end end diff --git a/test/unit/parse_tree_visitor_test.rb b/test/unit/parse_tree_visitor_test.rb index 2c085b38..c3e74487 100644 --- a/test/unit/parse_tree_visitor_test.rb +++ b/test/unit/parse_tree_visitor_test.rb @@ -159,6 +159,13 @@ class ParseTreeVisitorTest < Minitest::Test ) end + def test_for_range + assert_equal( + ["test"], + visit(%({% for x in (1..test) %}{% endfor %})) + ) + end + def test_tablerow_in assert_equal( ["test"], From e86fe272599596e14d40a19ceb5ab7f5e7207017 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Thu, 9 Sep 2021 11:22:19 -0400 Subject: [PATCH 2/6] Fix lint --- lib/liquid/condition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/liquid/condition.rb b/lib/liquid/condition.rb index 3dd433d6..786f9bc9 100644 --- a/lib/liquid/condition.rb +++ b/lib/liquid/condition.rb @@ -8,7 +8,7 @@ module Liquid # c = Condition.new(1, '==', 1) # c.evaluate #=> true # - class Condition #:nodoc: + class Condition # :nodoc: @@operators = { '==' => ->(cond, left, right) { cond.send(:equal_variables, left, right) }, '!=' => ->(cond, left, right) { !cond.send(:equal_variables, left, right) }, From a5369c26a8d47107c8e3bb043ba7c10ca14b7ebd Mon Sep 17 00:00:00 2001 From: Zac Clay Date: Thu, 9 Sep 2021 14:23:11 -0400 Subject: [PATCH 3/6] Add missing quote in comment (#1468) --- lib/liquid/context.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/liquid/context.rb b/lib/liquid/context.rb index 605fddec..3d6ffc96 100644 --- a/lib/liquid/context.rb +++ b/lib/liquid/context.rb @@ -124,7 +124,7 @@ module Liquid # context['var'] = 'hi' # end # - # context['var] #=> nil + # context['var'] #=> nil def stack(new_scope = {}) push(new_scope) yield From b01de9d325d6e645a4c9571a3be3c1456f14f9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Cournoyer?= Date: Thu, 9 Sep 2021 14:28:45 -0400 Subject: [PATCH 4/6] Prep for 5.1.0 release --- History.md | 7 ++++++- lib/liquid/version.rb | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/History.md b/History.md index 507a4a2f..b73e1486 100644 --- a/History.md +++ b/History.md @@ -1,12 +1,17 @@ # Liquid Change Log -## 5.0.2 (unreleased) +## 5.1.0 / 2021-09-09 ### Features * Add `base64_encode`, `base64_decode`, `base64_url_safe_encode`, and `base64_url_safe_decode` filters (#1450) [Daniel Insley] +* Introduce `to_liquid_value` in `Liquid::Drop` (#1441) [Michael Go] ### Fixes * Fix support for using a String subclass for the liquid source (#1421) [Dylan Thacker-Smith] +* Add `ParseTreeVisitor` to `RangeLookup` (#1470) [CP Clermont] +* Use `Utils.to_liquid_value` in conditionals (#1458, #1457) [Michael Go] +* Use `to_liquid_value` in `default` filter (#1454) [Michael Go] +* Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith] ## 5.0.1 / 2021-03-24 diff --git a/lib/liquid/version.rb b/lib/liquid/version.rb index 724bca4c..93388f2f 100644 --- a/lib/liquid/version.rb +++ b/lib/liquid/version.rb @@ -2,5 +2,5 @@ # frozen_string_literal: true module Liquid - VERSION = "5.0.2.alpha" + VERSION = "5.1.0" end From 7c4114671b603e785efb6a29770733bbfb29a5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Cournoyer?= Date: Mon, 13 Sep 2021 10:53:46 -0400 Subject: [PATCH 5/6] Remove to_liquid_value fixes in changelog Co-authored-by: Dylan Thacker-Smith --- History.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/History.md b/History.md index b73e1486..a3a62052 100644 --- a/History.md +++ b/History.md @@ -9,8 +9,6 @@ ### Fixes * Fix support for using a String subclass for the liquid source (#1421) [Dylan Thacker-Smith] * Add `ParseTreeVisitor` to `RangeLookup` (#1470) [CP Clermont] -* Use `Utils.to_liquid_value` in conditionals (#1458, #1457) [Michael Go] -* Use `to_liquid_value` in `default` filter (#1454) [Michael Go] * Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith] ## 5.0.1 / 2021-03-24 From db3999a008e5b5ac999328bef55baccdd18e5089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20S=C3=B8gaard?= Date: Thu, 16 Sep 2021 16:02:39 +0200 Subject: [PATCH 6/6] Improve where filter tests (#1472) --- test/integration/standard_filter_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index 482d9a33..f80d7ad0 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -770,6 +770,18 @@ class StandardFiltersTest < Minitest::Test assert_equal(expectation, @filters.where(input, "ok")) end + def test_where_string_keys + input = [ + "alpha", "beta", "gamma", "delta" + ] + + expectation = [ + "beta", + ] + + assert_equal(expectation, @filters.where(input, "be")) + end + def test_where_no_key_set input = [ { "handle" => "alpha", "ok" => true },