dunnololtest

This commit is contained in:
Florian Weingarten
2019-04-11 13:55:24 +01:00
parent 78d2a437ff
commit 250048717c
2 changed files with 19 additions and 1 deletions

View File

@@ -143,7 +143,8 @@ module Liquid
# Fetches an object starting at the local scope and then moving up the hierachy
def find_variable(key, raise_on_not_found: true)
scope = @scope if @scope.key?(key)
value = @scope[key]
scope = @scope if value != nil
if scope.nil?
index = @environments.find_index do |e|

View File

@@ -368,6 +368,23 @@ HERE
assert_template_result(expected, template, assigns)
end
def test_overwriting_internal_variable
template = <<-END_TEMPLATE
{% assign forloop = 'first' %}
{% for item in items %}
{{ forloop }}
{% assign forloop = 'second' %}
{{ forloop }}
{% endfor %}
{{ forloop }}
END_TEMPLATE
result = Liquid::Template.parse(template).render('items' => '1')
assert_equal 'Liquid::ForloopDrop Liquid::ForloopDrop second', result.split.map(&:strip).join(' ')
end
class LoaderDrop < Liquid::Drop
attr_accessor :each_called, :load_slice_called