mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Fix commit 7bbb4ff84f so it's backwards-compatible
This commit is contained in:
@@ -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(context, template_name)
|
||||
def read_template_file(template_path, context)
|
||||
raise FileSystemError, "This liquid context does not allow includes."
|
||||
end
|
||||
end
|
||||
@@ -38,8 +38,7 @@ module Liquid
|
||||
@root = root
|
||||
end
|
||||
|
||||
def read_template_file(context, template_name)
|
||||
template_path = context[template_name]
|
||||
def read_template_file(template_path, context)
|
||||
full_path = full_path(template_path)
|
||||
raise FileSystemError, "No such template '#{template_path}'" unless File.exists?(full_path)
|
||||
|
||||
|
||||
@@ -22,12 +22,10 @@ module Liquid
|
||||
|
||||
def parse(tokens)
|
||||
end
|
||||
|
||||
|
||||
def render(context)
|
||||
file_system = context.registers[:file_system] || Liquid::Template.file_system
|
||||
source = file_system.read_template_file(context, @template_name)
|
||||
source = _read_template_from_file_system(context)
|
||||
partial = Liquid::Template.parse(source)
|
||||
|
||||
variable = context[@variable_name || @template_name[1..-2]]
|
||||
|
||||
context.stack do
|
||||
@@ -50,6 +48,21 @@ module Liquid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def _read_template_from_file_system(context)
|
||||
file_system = context.registers[:file_system] || Liquid::Template.file_system
|
||||
|
||||
# make read_template_file call backwards-compatible.
|
||||
case file_system.method(:read_template_file).arity
|
||||
when 1
|
||||
file_system.read_template_file(context[@template_name])
|
||||
when 2
|
||||
file_system.read_template_file(context[@template_name], context)
|
||||
else
|
||||
raise ArgumentError, "file_system.read_template_file expects two parameters: (template_name, context)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('include', Include)
|
||||
|
||||
Reference in New Issue
Block a user