Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-liquid for openSUSE:Factory checked in at 2022-02-07 23:37:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-liquid (Old) and /work/SRC/openSUSE:Factory/.rubygem-liquid.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-liquid" Mon Feb 7 23:37:44 2022 rev:7 rq:949086 version:5.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-liquid/rubygem-liquid.changes 2021-07-02 13:28:38.744211880 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-liquid.new.1898/rubygem-liquid.changes 2022-02-07 23:38:47.134159049 +0100 @@ -1,0 +2,18 @@ +Tue Jan 25 07:09:26 UTC 2022 - Stephan Kulow <[email protected]> + +updated to version 5.1.0 + see installed History.md + + ## 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] + * Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith] + + +------------------------------------------------------------------- Old: ---- liquid-5.0.1.gem New: ---- liquid-5.1.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-liquid.spec ++++++ --- /var/tmp/diff_new_pack.GIhG4d/_old 2022-02-07 23:38:47.586155957 +0100 +++ /var/tmp/diff_new_pack.GIhG4d/_new 2022-02-07 23:38:47.594155902 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-liquid # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-liquid -Version: 5.0.1 +Version: 5.1.0 Release: 0 %define mod_name liquid %define mod_full_name %{mod_name}-%{version} ++++++ liquid-5.0.1.gem -> liquid-5.1.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/History.md new/History.md --- old/History.md 2021-03-24 21:57:30.000000000 +0100 +++ new/History.md 2021-09-15 21:16:18.000000000 +0200 @@ -1,5 +1,16 @@ # Liquid Change Log +## 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] +* Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith] + ## 5.0.1 / 2021-03-24 ### Fixes Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/condition.rb new/lib/liquid/condition.rb --- old/lib/liquid/condition.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/condition.rb 2021-09-15 21:16:18.000000000 +0200 @@ -8,7 +8,7 @@ # 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) }, @@ -134,8 +134,8 @@ # return this as the result. return context.evaluate(left) if op.nil? - left = context.evaluate(left) - right = context.evaluate(right) + left = Liquid::Utils.to_liquid_value(context.evaluate(left)) + right = Liquid::Utils.to_liquid_value(context.evaluate(right)) operation = self.class.operators[op] || raise(Liquid::ArgumentError, "Unknown operator #{op}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/context.rb new/lib/liquid/context.rb --- old/lib/liquid/context.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/context.rb 2021-09-15 21:16:18.000000000 +0200 @@ -124,7 +124,7 @@ # context['var'] = 'hi' # end # - # context['var] #=> nil + # context['var'] #=> nil def stack(new_scope = {}) push(new_scope) yield diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/range_lookup.rb new/lib/liquid/range_lookup.rb --- old/lib/liquid/range_lookup.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/range_lookup.rb 2021-09-15 21:16:18.000000000 +0200 @@ -12,6 +12,8 @@ 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 @@ Utils.to_integer(input) end end + + class ParseTreeVisitor < Liquid::ParseTreeVisitor + def children + [@node.start_obj, @node.end_obj] + end + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/standardfilters.rb new/lib/liquid/standardfilters.rb --- old/lib/liquid/standardfilters.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/standardfilters.rb 2021-09-15 21:16:18.000000000 +0200 @@ -1,10 +1,12 @@ # frozen_string_literal: true require 'cgi' +require 'base64' require 'bigdecimal' module Liquid module StandardFilters + MAX_INT = (1 << 31) - 1 HTML_ESCAPE = { '&' => '&', '>' => '>', @@ -62,6 +64,26 @@ result end + def base64_encode(input) + Base64.strict_encode64(input.to_s) + end + + def base64_decode(input) + Base64.strict_decode64(input.to_s) + rescue ::ArgumentError + raise Liquid::ArgumentError, "invalid base64 provided to base64_decode" + end + + def base64_url_safe_encode(input) + Base64.urlsafe_encode64(input.to_s) + end + + def base64_url_safe_decode(input) + Base64.urlsafe_decode64(input.to_s) + rescue ::ArgumentError + raise Liquid::ArgumentError, "invalid base64 provided to base64_url_safe_decode" + end + def slice(input, offset, length = nil) offset = Utils.to_integer(offset) length = length ? Utils.to_integer(length) : 1 @@ -93,7 +115,13 @@ words = Utils.to_integer(words) words = 1 if words <= 0 - wordlist = input.split(" ", words + 1) + wordlist = begin + input.split(" ", words + 1) + rescue RangeError + raise if words + 1 < MAX_INT + # e.g. integer #{words} too big to convert to `int' + raise Liquid::ArgumentError, "integer #{words} too big for truncatewords" + end return input if wordlist.length <= words wordlist.pop @@ -440,7 +468,7 @@ # def default(input, default_value = '', options = {}) options = {} unless options.is_a?(Hash) - false_check = options['allow_false'] ? input.nil? : !input + false_check = options['allow_false'] ? input.nil? : !Liquid::Utils.to_liquid_value(input) false_check || (input.respond_to?(:empty?) && input.empty?) ? default_value : input end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/tags/case.rb new/lib/liquid/tags/case.rb --- old/lib/liquid/tags/case.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/tags/case.rb 2021-09-15 21:16:18.000000000 +0200 @@ -52,7 +52,14 @@ @blocks.each do |block| if block.else? block.attachment.render_to_output_buffer(context, output) if execute_else_block - elsif block.evaluate(context) + next + end + + result = Liquid::Utils.to_liquid_value( + block.evaluate(context) + ) + + if result execute_else_block = false block.attachment.render_to_output_buffer(context, output) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/tags/if.rb new/lib/liquid/tags/if.rb --- old/lib/liquid/tags/if.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/tags/if.rb 2021-09-15 21:16:18.000000000 +0200 @@ -50,7 +50,11 @@ def render_to_output_buffer(context, output) @blocks.each do |block| - if block.evaluate(context) + result = Liquid::Utils.to_liquid_value( + block.evaluate(context) + ) + + if result return block.attachment.render_to_output_buffer(context, output) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/tags/unless.rb new/lib/liquid/tags/unless.rb --- old/lib/liquid/tags/unless.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/tags/unless.rb 2021-09-15 21:16:18.000000000 +0200 @@ -11,13 +11,21 @@ def render_to_output_buffer(context, output) # First condition is interpreted backwards ( if not ) first_block = @blocks.first - unless first_block.evaluate(context) + result = Liquid::Utils.to_liquid_value( + first_block.evaluate(context) + ) + + unless result return first_block.attachment.render_to_output_buffer(context, output) end # After the first condition unless works just like if @blocks[1..-1].each do |block| - if block.evaluate(context) + result = Liquid::Utils.to_liquid_value( + block.evaluate(context) + ) + + if result return block.attachment.render_to_output_buffer(context, output) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/tokenizer.rb new/lib/liquid/tokenizer.rb --- old/lib/liquid/tokenizer.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/tokenizer.rb 2021-09-15 21:16:18.000000000 +0200 @@ -5,7 +5,7 @@ attr_reader :line_number, :for_liquid_tag def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false) - @source = source + @source = source.to_s.to_str @line_number = line_number || (line_numbers ? 1 : nil) @for_liquid_tag = for_liquid_tag @tokens = tokenize @@ -24,7 +24,7 @@ private def tokenize - return [] if @source.to_s.empty? + return [] if @source.empty? return @source.split("\n") if @for_liquid_tag diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/utils.rb new/lib/liquid/utils.rb --- old/lib/liquid/utils.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/utils.rb 2021-09-15 21:16:18.000000000 +0200 @@ -81,5 +81,13 @@ rescue ::ArgumentError nil end + + def self.to_liquid_value(obj) + # Enable "obj" to represent itself as a primitive value like integer, string, or boolean + return obj.to_liquid_value if obj.respond_to?(:to_liquid_value) + + # Otherwise return the object itself + obj + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/variable_lookup.rb new/lib/liquid/variable_lookup.rb --- old/lib/liquid/variable_lookup.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/variable_lookup.rb 2021-09-15 21:16:18.000000000 +0200 @@ -40,6 +40,9 @@ @lookups.each_index do |i| key = context.evaluate(@lookups[i]) + # Cast "key" to its liquid value to enable it to act as a primitive value + key = Liquid::Utils.to_liquid_value(key) + # If object is a hash- or array-like object we look for the # presence of the key and if its available we return it if object.respond_to?(:[]) && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/liquid/version.rb new/lib/liquid/version.rb --- old/lib/liquid/version.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/lib/liquid/version.rb 2021-09-15 21:16:18.000000000 +0200 @@ -2,5 +2,5 @@ # frozen_string_literal: true module Liquid - VERSION = "5.0.1" + VERSION = "5.1.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2021-03-24 21:57:30.000000000 +0100 +++ new/metadata 2021-09-15 21:16:18.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: liquid version: !ruby/object:Gem::Version - version: 5.0.1 + version: 5.1.0 platform: ruby authors: - Tobias L??tke autorequire: bindir: bin cert_chain: [] -date: 2021-03-24 00:00:00.000000000 Z +date: 2021-09-15 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -187,65 +187,65 @@ - !ruby/object:Gem::Version version: 1.3.7 requirements: [] -rubygems_version: 3.0.3 +rubygems_version: 3.2.20 signing_key: specification_version: 4 summary: A secure, non-evaling end user template engine with aesthetic markup. test_files: +- test/test_helper.rb - test/fixtures/en_locale.yml -- test/unit/condition_unit_test.rb -- test/unit/variable_unit_test.rb -- test/unit/template_unit_test.rb -- test/unit/strainer_template_unit_test.rb -- test/unit/file_system_unit_test.rb -- test/unit/static_registers_unit_test.rb -- test/unit/tags/for_tag_unit_test.rb -- test/unit/tags/if_tag_unit_test.rb -- test/unit/tags/case_tag_unit_test.rb - test/unit/strainer_factory_unit_test.rb -- test/unit/parse_tree_visitor_test.rb -- test/unit/lexer_unit_test.rb -- test/unit/block_unit_test.rb - test/unit/regexp_unit_test.rb +- test/unit/static_registers_unit_test.rb +- test/unit/template_unit_test.rb - test/unit/partial_cache_unit_test.rb +- test/unit/block_unit_test.rb +- test/unit/parse_tree_visitor_test.rb - test/unit/parser_unit_test.rb -- test/unit/tag_unit_test.rb - test/unit/i18n_unit_test.rb +- test/unit/file_system_unit_test.rb +- test/unit/tags/case_tag_unit_test.rb +- test/unit/tags/if_tag_unit_test.rb +- test/unit/tags/for_tag_unit_test.rb - test/unit/tokenizer_unit_test.rb - test/unit/template_factory_unit_test.rb -- test/test_helper.rb -- test/integration/blank_test.rb -- test/integration/standard_filter_test.rb +- test/unit/lexer_unit_test.rb +- test/unit/condition_unit_test.rb +- test/unit/tag_unit_test.rb +- test/unit/strainer_template_unit_test.rb +- test/unit/variable_unit_test.rb +- test/integration/error_handling_test.rb +- test/integration/tag_test.rb +- test/integration/filter_test.rb +- test/integration/context_test.rb +- test/integration/block_test.rb +- test/integration/template_test.rb +- test/integration/profiler_test.rb - test/integration/parsing_quirks_test.rb - test/integration/tag/disableable_test.rb -- test/integration/context_test.rb -- test/integration/error_handling_test.rb +- test/integration/trim_mode_test.rb +- test/integration/expression_test.rb +- test/integration/output_test.rb - test/integration/security_test.rb -- test/integration/capture_test.rb -- test/integration/assign_test.rb +- test/integration/drop_test.rb - test/integration/tags/increment_tag_test.rb -- test/integration/tags/break_tag_test.rb +- test/integration/tags/raw_tag_test.rb - test/integration/tags/if_else_tag_test.rb -- test/integration/tags/liquid_tag_test.rb -- test/integration/tags/for_tag_test.rb -- test/integration/tags/unless_else_tag_test.rb - test/integration/tags/include_tag_test.rb -- test/integration/tags/echo_test.rb - test/integration/tags/statements_test.rb +- test/integration/tags/break_tag_test.rb - test/integration/tags/render_tag_test.rb -- test/integration/tags/raw_tag_test.rb - test/integration/tags/continue_tag_test.rb - test/integration/tags/table_row_test.rb +- test/integration/tags/unless_else_tag_test.rb +- test/integration/tags/echo_test.rb - test/integration/tags/standard_tag_test.rb -- test/integration/variable_test.rb -- test/integration/template_test.rb -- test/integration/block_test.rb -- test/integration/profiler_test.rb -- test/integration/drop_test.rb -- test/integration/expression_test.rb -- test/integration/filter_test.rb +- test/integration/tags/liquid_tag_test.rb +- test/integration/tags/for_tag_test.rb +- test/integration/standard_filter_test.rb +- test/integration/blank_test.rb - test/integration/document_test.rb -- test/integration/trim_mode_test.rb -- test/integration/output_test.rb +- test/integration/variable_test.rb - test/integration/hash_ordering_test.rb -- test/integration/tag_test.rb +- test/integration/assign_test.rb +- test/integration/capture_test.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/integration/standard_filter_test.rb new/test/integration/standard_filter_test.rb --- old/test/integration/standard_filter_test.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/test/integration/standard_filter_test.rb 2021-09-15 21:16:18.000000000 +0200 @@ -145,6 +145,40 @@ assert_equal('<strong>Hulk</strong>', @filters.escape_once('<strong>Hulk</strong>')) end + def test_base64_encode + assert_equal('b25lIHR3byB0aHJlZQ==', @filters.base64_encode('one two three')) + assert_equal('', @filters.base64_encode(nil)) + end + + def test_base64_decode + assert_equal('one two three', @filters.base64_decode('b25lIHR3byB0aHJlZQ==')) + + exception = assert_raises(Liquid::ArgumentError) do + @filters.base64_decode("invalidbase64") + end + + assert_equal('Liquid error: invalid base64 provided to base64_decode', exception.message) + end + + def test_base64_url_safe_encode + assert_equal( + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXogQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVogMTIzNDU2Nzg5MCAhQCMkJV4mKigpLT1fKy8_Ljo7W117fVx8', + @filters.base64_url_safe_encode('abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 !@#$%^&*()-=_+/?.:;[]{}\|') + ) + assert_equal('', @filters.base64_url_safe_encode(nil)) + end + + def test_base64_url_safe_decode + assert_equal( + 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 !@#$%^&*()-=_+/?.:;[]{}\|', + @filters.base64_url_safe_decode('YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXogQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVogMTIzNDU2Nzg5MCAhQCMkJV4mKigpLT1fKy8_Ljo7W117fVx8') + ) + exception = assert_raises(Liquid::ArgumentError) do + @filters.base64_url_safe_decode("invalidbase64") + end + assert_equal('Liquid error: invalid base64 provided to base64_url_safe_decode', exception.message) + end + def test_url_encode assert_equal('foo%2B1%40example.com', @filters.url_encode('[email protected]')) assert_equal('1', @filters.url_encode(1)) @@ -178,6 +212,10 @@ assert_equal('one two three...', @filters.truncatewords("one two\tthree\nfour", 3)) assert_equal('one two...', @filters.truncatewords("one two three four", 2)) assert_equal('one...', @filters.truncatewords("one two three four", 0)) + exception = assert_raises(Liquid::ArgumentError) do + @filters.truncatewords("one two three four", 1 << 31) + end + assert_equal("Liquid error: integer #{1 << 31} too big for truncatewords", exception.message) end def test_strip_html @@ -690,6 +728,8 @@ assert_equal("bar", @filters.default([], "bar")) assert_equal("bar", @filters.default({}, "bar")) assert_template_result('bar', "{{ false | default: 'bar' }}") + assert_template_result('bar', "{{ drop | default: 'bar' }}", 'drop' => BooleanDrop.new(false)) + assert_template_result('Yay', "{{ drop | default: 'bar' }}", 'drop' => BooleanDrop.new(true)) end def test_default_handle_false @@ -700,6 +740,8 @@ assert_equal("bar", @filters.default([], "bar", "allow_false" => true)) assert_equal("bar", @filters.default({}, "bar", "allow_false" => true)) assert_template_result('false', "{{ false | default: 'bar', allow_false: true }}") + assert_template_result('Nay', "{{ drop | default: 'bar', allow_false: true }}", 'drop' => BooleanDrop.new(false)) + assert_template_result('Yay', "{{ drop | default: 'bar', allow_false: true }}", 'drop' => BooleanDrop.new(true)) end def test_cannot_access_private_methods diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/integration/template_test.rb new/test/integration/template_test.rb --- old/test/integration/template_test.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/test/integration/template_test.rb 2021-09-15 21:16:18.000000000 +0200 @@ -323,4 +323,18 @@ result = t.render('x' => 1, 'y' => 5) assert_equal('12345', result) end + + def test_source_string_subclass + string_subclass = Class.new(String) do + # E.g. ActiveSupport::SafeBuffer does this, so don't just rely on to_s to return a String + def to_s + self + end + end + source = string_subclass.new("{% assign x = 2 -%} x= {{- x }}") + assert_instance_of(string_subclass, source) + output = Template.parse(source).render! + assert_equal("x=2", output) + assert_instance_of(String, output) + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/integration/variable_test.rb new/test/integration/variable_test.rb --- old/test/integration/variable_test.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/test/integration/variable_test.rb 2021-09-15 21:16:18.000000000 +0200 @@ -15,6 +15,33 @@ assert_template_result('foobar', '{{ foo }}', 'foo' => ThingWithToLiquid.new) end + def test_variable_lookup_calls_to_liquid_value + assert_template_result('1', '{{ foo }}', 'foo' => IntegerDrop.new('1')) + assert_template_result('2', '{{ list[foo] }}', 'foo' => IntegerDrop.new('1'), 'list' => [1, 2, 3]) + assert_template_result('one', '{{ list[foo] }}', 'foo' => IntegerDrop.new('1'), 'list' => { 1 => 'one' }) + assert_template_result('Yay', '{{ foo }}', 'foo' => BooleanDrop.new(true)) + assert_template_result('YAY', '{{ foo | upcase }}', 'foo' => BooleanDrop.new(true)) + end + + def test_if_tag_calls_to_liquid_value + assert_template_result('one', '{% if foo == 1 %}one{% endif %}', 'foo' => IntegerDrop.new('1')) + assert_template_result('one', '{% if 0 < foo %}one{% endif %}', 'foo' => IntegerDrop.new('1')) + assert_template_result('one', '{% if foo > 0 %}one{% endif %}', 'foo' => IntegerDrop.new('1')) + assert_template_result('true', '{% if foo == true %}true{% endif %}', 'foo' => BooleanDrop.new(true)) + assert_template_result('true', '{% if foo %}true{% endif %}', 'foo' => BooleanDrop.new(true)) + + assert_template_result('', '{% if foo %}true{% endif %}', 'foo' => BooleanDrop.new(false)) + assert_template_result('', '{% if foo == true %}True{% endif %}', 'foo' => BooleanDrop.new(false)) + end + + def test_unless_tag_calls_to_liquid_value + assert_template_result('', '{% unless foo %}true{% endunless %}', 'foo' => BooleanDrop.new(true)) + end + + def test_case_tag_calls_to_liquid_value + assert_template_result('One', '{% case foo %}{% when 1 %}One{% endcase %}', 'foo' => IntegerDrop.new('1')) + end + def test_simple_with_whitespaces template = Template.parse(%( {{ test }} )) assert_equal(' worked ', template.render!('test' => 'worked')) @@ -104,4 +131,8 @@ def test_dynamic_find_var assert_template_result('bar', '{{ [key] }}', 'key' => 'foo', 'foo' => 'bar') end + + def test_raw_value_variable + assert_template_result('bar', '{{ [key] }}', 'key' => 'foo', 'foo' => 'bar') + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/test_helper.rb new/test/test_helper.rb --- old/test/test_helper.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/test/test_helper.rb 2021-09-15 21:16:18.000000000 +0200 @@ -119,6 +119,44 @@ end end +class IntegerDrop < Liquid::Drop + def initialize(value) + super() + @value = value.to_i + end + + def ==(other) + @value == other + end + + def to_s + @value.to_s + end + + def to_liquid_value + @value + end +end + +class BooleanDrop < Liquid::Drop + def initialize(value) + super() + @value = value + end + + def ==(other) + @value == other + end + + def to_liquid_value + @value + end + + def to_s + @value ? "Yay" : "Nay" + end +end + class ErrorDrop < Liquid::Drop def standard_error raise Liquid::StandardError, 'standard error' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/unit/parse_tree_visitor_test.rb new/test/unit/parse_tree_visitor_test.rb --- old/test/unit/parse_tree_visitor_test.rb 2021-03-24 21:57:30.000000000 +0100 +++ new/test/unit/parse_tree_visitor_test.rb 2021-09-15 21:16:18.000000000 +0200 @@ -159,6 +159,13 @@ ) end + def test_for_range + assert_equal( + ["test"], + visit(%({% for x in (1..test) %}{% endfor %})) + ) + end + def test_tablerow_in assert_equal( ["test"],
