mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 09:15:41 +03:00
Clean up whitespace collapsing a bit
This commit is contained in:
@@ -7,8 +7,8 @@ module Liquid
|
||||
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
||||
ContentOfVariable = /^#{VariableStart}(.*)#{VariableEnd}$/o
|
||||
|
||||
def self.blank?
|
||||
false
|
||||
def blank?
|
||||
@blank || false
|
||||
end
|
||||
|
||||
def parse(tokens)
|
||||
@@ -25,14 +25,13 @@ module Liquid
|
||||
# proceed
|
||||
if block_delimiter == $1
|
||||
end_tag
|
||||
@blank = true if self.class.blank?
|
||||
return
|
||||
end
|
||||
|
||||
# fetch the tag from registered blocks
|
||||
if tag = Template.tags[$1]
|
||||
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
|
||||
else
|
||||
# this tag is not registered with the system
|
||||
|
||||
@@ -19,8 +19,8 @@ module Liquid
|
||||
''
|
||||
end
|
||||
|
||||
def self.blank?
|
||||
true
|
||||
def blank?
|
||||
@blank || true
|
||||
end
|
||||
end # Tag
|
||||
end # Tag
|
||||
|
||||
@@ -31,7 +31,7 @@ module Liquid
|
||||
''
|
||||
end
|
||||
|
||||
def self.blank?
|
||||
def blank?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module Liquid
|
||||
''
|
||||
end
|
||||
|
||||
def self.blank?
|
||||
def blank?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,9 @@ module Liquid
|
||||
value.to_s
|
||||
end
|
||||
|
||||
private
|
||||
def blank?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('increment', Increment)
|
||||
|
||||
@@ -61,6 +61,10 @@ class BlankTest < Test::Unit::TestCase
|
||||
assert_template_result(body*(N+1), wrap(body))
|
||||
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
|
||||
assert_template_result(" "*(N+1), wrap(" {% raw %} {% endraw %}"))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user