Support for passing variables to snippets in subdirs

Now you can use "include 'some/snippet' with variable".
This commit is contained in:
Joost Hietbrink
2013-10-16 11:55:12 +02:00
parent 9b910a4e6d
commit 5eddfe87d0

View File

@@ -51,13 +51,14 @@ module Liquid
context[key] = context[value]
end
context_variable_name = @template_name[1..-2].split('/').last # for a snippet in a subdir only use the filename
if variable.is_a?(Array)
variable.collect do |var|
context[@template_name[1..-2]] = var
context[context_variable_name] = var
partial.render(context)
end
else
context[@template_name[1..-2]] = variable
context[context_variable_name] = variable
partial.render(context)
end
end