mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Make sure include tags are never blank
This commit is contained in:
@@ -38,6 +38,10 @@ module Liquid
|
|||||||
def parse(tokens)
|
def parse(tokens)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def blank?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
partial = load_cached_partial(context)
|
partial = load_cached_partial(context)
|
||||||
variable = context[@variable_name || @template_name[1..-2]]
|
variable = context[@variable_name || @template_name[1..-2]]
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BlankTestFileSystem
|
||||||
|
def read_template_file(template_path, context)
|
||||||
|
template_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class BlankTest < Test::Unit::TestCase
|
class BlankTest < Test::Unit::TestCase
|
||||||
include Liquid
|
include Liquid
|
||||||
N = 10
|
N = 10
|
||||||
@@ -77,4 +83,11 @@ class BlankTest < Test::Unit::TestCase
|
|||||||
assert_template_result(" "*(N+1), wrap(' {{ "" }} '))
|
assert_template_result(" "*(N+1), wrap(' {{ "" }} '))
|
||||||
assert_template_result(" "*(N+1), wrap("{% assign foo = ' ' %}{{ foo }}"))
|
assert_template_result(" "*(N+1), wrap("{% assign foo = ' ' %}{{ foo }}"))
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user