mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-04 01:25:14 -07:00
Clean up whitespace collapsing a bit
This commit is contained in:
+3
-4
@@ -7,8 +7,8 @@ module Liquid
|
|||||||
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
||||||
ContentOfVariable = /^#{VariableStart}(.*)#{VariableEnd}$/o
|
ContentOfVariable = /^#{VariableStart}(.*)#{VariableEnd}$/o
|
||||||
|
|
||||||
def self.blank?
|
def blank?
|
||||||
false
|
@blank || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(tokens)
|
def parse(tokens)
|
||||||
@@ -25,14 +25,13 @@ module Liquid
|
|||||||
# proceed
|
# proceed
|
||||||
if block_delimiter == $1
|
if block_delimiter == $1
|
||||||
end_tag
|
end_tag
|
||||||
@blank = true if self.class.blank?
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# 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 if new_tag.is_a?(Block) && !new_tag.blank
|
@blank = false unless 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
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ module Liquid
|
|||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.blank?
|
def blank?
|
||||||
true
|
@blank || true
|
||||||
end
|
end
|
||||||
end # Tag
|
end # Tag
|
||||||
end # Tag
|
end # Tag
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ module Liquid
|
|||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.blank?
|
def blank?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module Liquid
|
|||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.blank?
|
def blank?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ module Liquid
|
|||||||
value.to_s
|
value.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def blank?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Template.register_tag('increment', Increment)
|
Template.register_tag('increment', Increment)
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ class BlankTest < Test::Unit::TestCase
|
|||||||
assert_template_result(body*(N+1), wrap(body))
|
assert_template_result(body*(N+1), wrap(body))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_increment_is_not_blank
|
||||||
|
assert_template_result(" 0"*2*(N+1), wrap("{% assign foo = 0 %} {% increment foo %} {% decrement foo %}"))
|
||||||
|
end
|
||||||
|
|
||||||
def test_raw_is_not_blank
|
def test_raw_is_not_blank
|
||||||
assert_template_result(" "*(N+1), wrap(" {% raw %} {% endraw %}"))
|
assert_template_result(" "*(N+1), wrap(" {% raw %} {% endraw %}"))
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user