now able to set file_system for include tag through registers

This commit is contained in:
James MacAulay
2009-08-06 18:24:27 -04:00
parent 7ff4352de2
commit a4d7c80ce0
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ module Liquid
end
def render(context)
source = Liquid::Template.file_system.read_template_file(context[@template_name])
file_system = context.registers[:file_system] || Liquid::Template.file_system
source = file_system.read_template_file(context[@template_name])
partial = Liquid::Template.parse(source)
variable = context[@variable_name || @template_name[1..-2]]
+14
View File
@@ -24,12 +24,21 @@ class TestFileSystem
when "recursively_nested_template"
"-{% include 'recursively_nested_template' %}"
when "pick_a_source"
"from TestFileSystem"
else
template_path
end
end
end
class OtherFileSystem
def read_template_file(template_path)
'from OtherFileSystem'
end
end
class IncludeTagTest < Test::Unit::TestCase
include Liquid
@@ -37,6 +46,11 @@ class IncludeTagTest < Test::Unit::TestCase
Liquid::Template.file_system = TestFileSystem.new
end
def test_include_tag_looks_for_file_system_in_registers_first
assert_equal 'from OtherFileSystem',
Template.parse("{% include 'pick_a_source' %}").render({}, :registers => {:file_system => OtherFileSystem.new})
end
def test_include_tag_with
assert_equal "Product: Draft 151cm ",