mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07:00
Push to for_stack at the beginning of For#render
This commit is contained in:
@@ -70,6 +70,9 @@ module Liquid
|
|||||||
for_offsets = context.registers[:for] ||= Hash.new(0)
|
for_offsets = context.registers[:for] ||= Hash.new(0)
|
||||||
for_stack = context.registers[:for_stack] ||= []
|
for_stack = context.registers[:for_stack] ||= []
|
||||||
|
|
||||||
|
parent_loop = for_stack.last
|
||||||
|
for_stack.push(nil)
|
||||||
|
|
||||||
collection = context.evaluate(@collection_name)
|
collection = context.evaluate(@collection_name)
|
||||||
collection = collection.to_a if collection.is_a?(Range)
|
collection = collection.to_a if collection.is_a?(Range)
|
||||||
|
|
||||||
@@ -98,9 +101,6 @@ module Liquid
|
|||||||
# Store our progress through the collection for the continue flag
|
# Store our progress through the collection for the continue flag
|
||||||
for_offsets[@name] = from + segment.length
|
for_offsets[@name] = from + segment.length
|
||||||
|
|
||||||
parent_loop = for_stack.last
|
|
||||||
for_stack.push(nil)
|
|
||||||
|
|
||||||
context.stack do
|
context.stack do
|
||||||
segment.each_with_index do |item, index|
|
segment.each_with_index do |item, index|
|
||||||
context[@variable_name] = item
|
context[@variable_name] = item
|
||||||
|
|||||||
@@ -313,6 +313,10 @@ HERE
|
|||||||
'outer' => [[1, 1, 1], [1, 1, 1]])
|
'outer' => [[1, 1, 1], [1, 1, 1]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_inner_for_over_empty_input
|
||||||
|
assert_template_result 'oo', '{% for a in (1..2) %}o{% for b in empty %}{% endfor %}{% endfor %}'
|
||||||
|
end
|
||||||
|
|
||||||
def test_blank_string_not_iterable
|
def test_blank_string_not_iterable
|
||||||
assert_template_result('', "{% for char in characters %}I WILL NOT BE OUTPUT{% endfor %}", 'characters' => '')
|
assert_template_result('', "{% for char in characters %}I WILL NOT BE OUTPUT{% endfor %}", 'characters' => '')
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user