mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 18:25:41 +03:00
Support for passing variables to snippets in subdirs
Now you can use "include 'some/snippet' with variable".
This commit is contained in:
@@ -51,13 +51,14 @@ module Liquid
|
|||||||
context[key] = context[value]
|
context[key] = context[value]
|
||||||
end
|
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)
|
if variable.is_a?(Array)
|
||||||
variable.collect do |var|
|
variable.collect do |var|
|
||||||
context[@template_name[1..-2]] = var
|
context[context_variable_name] = var
|
||||||
partial.render(context)
|
partial.render(context)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
context[@template_name[1..-2]] = variable
|
context[context_variable_name] = variable
|
||||||
partial.render(context)
|
partial.render(context)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user