From 22568080b1cb6f19969d55d68dc39b5c04a37b17 Mon Sep 17 00:00:00 2001 From: Watson Date: Wed, 16 Mar 2022 12:33:45 +0900 Subject: [PATCH] Revert "Use strip & empty? to detect Whitespaces" This reverts commit dd7ed00ec4e2d26172642add35583a86e25dabe0. --- lib/liquid/block_body.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index 8de7f6cb..2921ce88 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -7,6 +7,7 @@ module Liquid LiquidTagToken = /\A\s*(\w+)\s*(.*?)\z/o FullToken = /\A#{TagStart}#{WhitespaceControl}?(\s*)(\w+)(\s*)(.*?)#{WhitespaceControl}?#{TagEnd}\z/om ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om + WhitespaceOrNothing = /\A\s*\z/ TAGSTART = "{%" VARSTART = "{{" @@ -36,7 +37,7 @@ module Liquid private def parse_for_liquid_tag(tokenizer, parse_context) while (token = tokenizer.shift) - unless token.strip.empty? + unless token.empty? || token =~ WhitespaceOrNothing unless token =~ LiquidTagToken # line isn't empty but didn't match tag syntax, yield and let the # caller raise a syntax error @@ -149,7 +150,7 @@ module Liquid end parse_context.trim_whitespace = false @nodelist << token - @blank &&= token.strip.empty? + @blank &&= !!(token =~ WhitespaceOrNothing) end parse_context.line_number = tokenizer.line_number end