Make sure include tags are never blank

This commit is contained in:
Florian Weingarten
2013-07-02 13:57:27 -04:00
parent 40a37c3fb6
commit b53601100f
2 changed files with 17 additions and 0 deletions

View File

@@ -38,6 +38,10 @@ module Liquid
def parse(tokens)
end
def blank?
false
end
def render(context)
partial = load_cached_partial(context)
variable = context[@variable_name || @template_name[1..-2]]

View File

@@ -1,5 +1,11 @@
require 'test_helper'
class BlankTestFileSystem
def read_template_file(template_path, context)
template_path
end
end
class BlankTest < Test::Unit::TestCase
include Liquid
N = 10
@@ -77,4 +83,11 @@ class BlankTest < Test::Unit::TestCase
assert_template_result(" "*(N+1), wrap(' {{ "" }} '))
assert_template_result(" "*(N+1), wrap("{% assign foo = ' ' %}{{ foo }}"))
end
def test_include_is_blank
Liquid::Template.file_system = BlankTestFileSystem.new
assert_equal "foobar"*(N+1), Template.parse(wrap("{% include 'foobar' %}")).render()
assert_equal " foobar "*(N+1), Template.parse(wrap("{% include ' foobar ' %}")).render()
assert_equal " ", Template.parse(" {% include ' ' %} ").render()
end
end