mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Clean up whitespace collapsing
This commit is contained in:
+3
-5
@@ -1,7 +1,5 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class Block < Tag
|
class Block < Tag
|
||||||
attr_reader :blank
|
|
||||||
|
|
||||||
IsTag = /^#{TagStart}/o
|
IsTag = /^#{TagStart}/o
|
||||||
IsVariable = /^#{VariableStart}/o
|
IsVariable = /^#{VariableStart}/o
|
||||||
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
||||||
@@ -31,7 +29,7 @@ module Liquid
|
|||||||
# fetch the tag from registered blocks
|
# fetch the tag from registered blocks
|
||||||
if tag = Template.tags[$1]
|
if tag = Template.tags[$1]
|
||||||
new_tag = tag.new($1, $2, tokens)
|
new_tag = tag.new($1, $2, tokens)
|
||||||
@blank = false unless new_tag.blank?
|
@blank &&= new_tag.blank?
|
||||||
@nodelist << new_tag
|
@nodelist << new_tag
|
||||||
else
|
else
|
||||||
# this tag is not registered with the system
|
# this tag is not registered with the system
|
||||||
@@ -48,7 +46,7 @@ module Liquid
|
|||||||
# pass
|
# pass
|
||||||
else
|
else
|
||||||
@nodelist << token
|
@nodelist << token
|
||||||
@blank = false unless token =~ /\A\s*\z/
|
@blank &&= (token =~ /\A\s*\z/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,7 +119,7 @@ module Liquid
|
|||||||
context.resource_limits[:reached] = true
|
context.resource_limits[:reached] = true
|
||||||
raise MemoryError.new("Memory limits exceeded")
|
raise MemoryError.new("Memory limits exceeded")
|
||||||
end
|
end
|
||||||
unless token.respond_to?(:blank) && token.blank
|
unless token.is_a?(Block) && token.blank?
|
||||||
output << token_output
|
output << token_output
|
||||||
end
|
end
|
||||||
rescue MemoryError => e
|
rescue MemoryError => e
|
||||||
|
|||||||
Reference in New Issue
Block a user