mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
dunnololtest
This commit is contained in:
@@ -143,7 +143,8 @@ module Liquid
|
|||||||
|
|
||||||
# Fetches an object starting at the local scope and then moving up the hierachy
|
# Fetches an object starting at the local scope and then moving up the hierachy
|
||||||
def find_variable(key, raise_on_not_found: true)
|
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?
|
if scope.nil?
|
||||||
index = @environments.find_index do |e|
|
index = @environments.find_index do |e|
|
||||||
|
|||||||
@@ -368,6 +368,23 @@ HERE
|
|||||||
assert_template_result(expected, template, assigns)
|
assert_template_result(expected, template, assigns)
|
||||||
end
|
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
|
class LoaderDrop < Liquid::Drop
|
||||||
attr_accessor :each_called, :load_slice_called
|
attr_accessor :each_called, :load_slice_called
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user