From 1c8460c58c5a810a483f7b1bb77fbe7ff955bf82 Mon Sep 17 00:00:00 2001 From: Michael Go Date: Fri, 15 Nov 2024 17:21:03 -0400 Subject: [PATCH] code styling --- lib/liquid/lexer.rb | 2 +- lib/liquid/tokenizer.rb | 2 +- test/integration/tags/for_tag_test.rb | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/liquid/lexer.rb b/lib/liquid/lexer.rb index c2adec78f..4e8d3d6ef 100644 --- a/lib/liquid/lexer.rb +++ b/lib/liquid/lexer.rb @@ -164,7 +164,7 @@ def string_scanner end def initialize(input) - @ss = Lexer2.string_scanner + @ss = self.class.string_scanner @ss.string = input end diff --git a/lib/liquid/tokenizer.rb b/lib/liquid/tokenizer.rb index 9541d0b38..99c66d507 100644 --- a/lib/liquid/tokenizer.rb +++ b/lib/liquid/tokenizer.rb @@ -91,7 +91,7 @@ def tokenize if @for_liquid_tag @tokens = @source.split("\n") else - @ss = Tokenizer2.string_scanner + @ss = self.class.string_scanner @ss.string = @source @tokens << shift_normal until @ss.eos? end diff --git a/test/integration/tags/for_tag_test.rb b/test/integration/tags/for_tag_test.rb index 5b81e1109..901359340 100644 --- a/test/integration/tags/for_tag_test.rb +++ b/test/integration/tags/for_tag_test.rb @@ -99,6 +99,15 @@ def test_for_else assert_template_result('+++', '{%for item in array%}+{%else%}-{%endfor%}', { 'array' => [1, 2, 3] }) assert_template_result('-', '{%for item in array%}+{%else%}-{%endfor%}', { 'array' => [] }) assert_template_result('-', '{%for item in array%}+{%else%}-{%endfor%}', { 'array' => nil }) + + template = <<~LIQUID + {%- for item in array -%} + {%- else -%} + forloop.index: {{ forloop.index }} + {%- endfor -%} + LIQUID + + assert_template_result('forloop.index: ', template, { 'array' => nil }) end def test_limiting