diff --git a/lib/liquid/file_system.rb b/lib/liquid/file_system.rb index 8c6b76d..31f5dd2 100644 --- a/lib/liquid/file_system.rb +++ b/lib/liquid/file_system.rb @@ -14,7 +14,7 @@ module Liquid # This will parse the template with a LocalFileSystem implementation rooted at 'template_path'. class BlankFileSystem # Called by Liquid to retrieve a template file - def read_template_file(template_path) + def read_template_file(context, template_name) raise FileSystemError, "This liquid context does not allow includes." end end @@ -38,7 +38,8 @@ module Liquid @root = root end - def read_template_file(template_path) + def read_template_file(context, template_name) + template_path = context[template_name] full_path = full_path(template_path) raise FileSystemError, "No such template '#{template_path}'" unless File.exists?(full_path) diff --git a/lib/liquid/tags/include.rb b/lib/liquid/tags/include.rb index 3c74d72..8bee9fa 100644 --- a/lib/liquid/tags/include.rb +++ b/lib/liquid/tags/include.rb @@ -25,7 +25,7 @@ module Liquid def render(context) file_system = context.registers[:file_system] || Liquid::Template.file_system - source = file_system.read_template_file(context[@template_name]) + source = file_system.read_template_file(context, @template_name) partial = Liquid::Template.parse(source) variable = context[@variable_name || @template_name[1..-2]] diff --git a/test/lib/liquid/file_system_test.rb b/test/lib/liquid/file_system_test.rb index bbdffef..a7413cf 100644 --- a/test/lib/liquid/file_system_test.rb +++ b/test/lib/liquid/file_system_test.rb @@ -5,7 +5,7 @@ class FileSystemTest < Test::Unit::TestCase def test_default assert_raise(FileSystemError) do - BlankFileSystem.new.read_template_file("dummy") + BlankFileSystem.new.read_template_file({'dummy'=>'smarty'}, "dummy") end end diff --git a/test/lib/liquid/include_tag_test.rb b/test/lib/liquid/include_tag_test.rb index ca1e34c..814322c 100644 --- a/test/lib/liquid/include_tag_test.rb +++ b/test/lib/liquid/include_tag_test.rb @@ -1,7 +1,8 @@ require 'test_helper' class TestFileSystem - def read_template_file(template_path) + def read_template_file(context, template_name) + template_path = context[template_name] case template_path when "product" "Product: {{ product.title }} " @@ -34,7 +35,8 @@ class TestFileSystem end class OtherFileSystem - def read_template_file(template_path) + def read_template_file(context, template_name) + template_path = context[template_name] 'from OtherFileSystem' end end @@ -104,7 +106,7 @@ class IncludeTagTest < Test::Unit::TestCase def test_recursively_included_template_does_not_produce_endless_loop infinite_file_system = Class.new do - def read_template_file(template_path) + def read_template_file(context, template_name) "-{% include 'loop' %}" end end