mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Add blank scope constant
This commit is contained in:
@@ -15,6 +15,8 @@ module Liquid
|
|||||||
attr_reader :scopes, :errors, :registers, :environments, :resource_limits, :static_registers, :static_environments
|
attr_reader :scopes, :errors, :registers, :environments, :resource_limits, :static_registers, :static_environments
|
||||||
attr_accessor :exception_renderer, :template_name, :partial, :global_filter, :strict_variables, :strict_filters
|
attr_accessor :exception_renderer, :template_name, :partial, :global_filter, :strict_variables, :strict_filters
|
||||||
|
|
||||||
|
BLANK_SCOPE = {}
|
||||||
|
|
||||||
# rubocop:disable Metrics/ParameterLists
|
# rubocop:disable Metrics/ParameterLists
|
||||||
def self.build(environments: {}, outer_scope: {}, registers: {}, rethrow_errors: false, resource_limits: nil, static_registers: {}, static_environments: {})
|
def self.build(environments: {}, outer_scope: {}, registers: {}, rethrow_errors: false, resource_limits: nil, static_registers: {}, static_environments: {})
|
||||||
new(environments, outer_scope, registers, rethrow_errors, resource_limits, static_registers, static_environments)
|
new(environments, outer_scope, registers, rethrow_errors, resource_limits, static_registers, static_environments)
|
||||||
@@ -194,7 +196,7 @@ module Liquid
|
|||||||
scope = (index = @scopes.find_index { |s| s.key?(key) }) && @scopes[index]
|
scope = (index = @scopes.find_index { |s| s.key?(key) }) && @scopes[index]
|
||||||
scope ||= (index = @environments.find_index { |s| s.key?(key) || !s.default_proc.nil? }) && @environments[index]
|
scope ||= (index = @environments.find_index { |s| s.key?(key) || !s.default_proc.nil? }) && @environments[index]
|
||||||
scope ||= (index = @static_environments.find_index { |s| s.key?(key) }) && @static_environments[index]
|
scope ||= (index = @static_environments.find_index { |s| s.key?(key) }) && @static_environments[index]
|
||||||
scope ||= {}
|
scope ||= BLANK_SCOPE
|
||||||
|
|
||||||
variable = lookup_and_evaluate(scope, key, raise_on_not_found: raise_on_not_found).to_liquid
|
variable = lookup_and_evaluate(scope, key, raise_on_not_found: raise_on_not_found).to_liquid
|
||||||
variable.context = self if variable.respond_to?(:context=)
|
variable.context = self if variable.respond_to?(:context=)
|
||||||
|
|||||||
Reference in New Issue
Block a user