Add blank test for case tags

This commit is contained in:
Florian Weingarten
2013-07-02 18:08:20 -04:00
parent cd3f976288
commit 0f38fe3596
3 changed files with 5 additions and 9 deletions

View File

@@ -62,7 +62,6 @@ module Liquid
end
def record_else_condition(markup)
if not markup.strip.empty?
raise SyntaxError.new("Syntax Error in tag 'case' - Valid else condition: {% else %} (no parameters) ")
end
@@ -71,8 +70,6 @@ module Liquid
block.attach(@nodelist)
@blocks << block
end
end
Template.register_tag('case', Case)

View File

@@ -1,5 +1,4 @@
module Liquid
# If is the conditional block
#
# {% if user.admin %}
@@ -10,7 +9,6 @@ module Liquid
#
# There are {% if count < 5 %} less {% else %} more {% endif %} items than you need.
#
#
class If < Block
SyntaxHelp = "Syntax Error in tag 'if' - Valid syntax: if [expression]"
Syntax = /(#{QuotedFragment})\s*([=!<>a-z_]+)?\s*(#{QuotedFragment})?/o
@@ -18,9 +16,7 @@ module Liquid
def initialize(tag_name, markup, tokens)
@blocks = []
push_block('if', markup)
super
end
@@ -71,8 +67,6 @@ module Liquid
@blocks.push(block)
@nodelist = block.attach(Array.new)
end
end
Template.register_tag('if', If)

View File

@@ -90,4 +90,9 @@ class BlankTest < Test::Unit::TestCase
assert_equal " foobar "*(N+1), Template.parse(wrap("{% include ' foobar ' %}")).render()
assert_equal " ", Template.parse(" {% include ' ' %} ").render()
end
def test_case_is_blank
assert_template_result("", wrap(" {% assign foo = 'bar' %} {% case foo %} {% when 'bar' %} {% when 'whatever' %} {% else %} {% endcase %} "))
assert_template_result("", wrap(" {% assign foo = 'else' %} {% case foo %} {% when 'bar' %} {% when 'whatever' %} {% else %} {% endcase %} "))
end
end