Add concept of Liquid::Environment (#1815)

* Add concept of `Liquid::World`

* Rename `World` to `Environment`
This commit is contained in:
Ian Ker-Seymer
2024-08-07 15:00:44 -04:00
committed by GitHub
parent a0411e0927
commit fb6634f454
38 changed files with 463 additions and 226 deletions
+4 -3
View File
@@ -3,9 +3,10 @@
module Liquid
class ParseContext
attr_accessor :locale, :line_number, :trim_whitespace, :depth
attr_reader :partial, :warnings, :error_mode
attr_reader :partial, :warnings, :error_mode, :environment
def initialize(options = {})
def initialize(options = Const::EMPTY_HASH)
@environment = options.fetch(:environment, Environment.default)
@template_options = options ? options.dup : {}
@locale = @template_options[:locale] ||= I18n.new
@@ -35,7 +36,7 @@ module Liquid
@partial = value
@options = value ? partial_options : @template_options
@error_mode = @options[:error_mode] || Template.error_mode
@error_mode = @options[:error_mode] || @environment.error_mode
end
def partial_options