Ensure that partial caches are shared with subcontexts

Make Context use StaticRegisters by default. This makes it easier to
ensure that all subcontexts share the same static registers.

Co-authored-by: Dylan Thacker-Smith <[email protected]>
This commit is contained in:
Chris AtLee
2022-04-08 10:05:58 -04:00
co-authored by Dylan Thacker-Smith
parent 1cae1e497f
commit 6c2c621712
7 changed files with 66 additions and 9 deletions
+5 -1
View File
@@ -28,7 +28,7 @@ module Liquid
@static_environments = [static_environments].flat_map(&:freeze).freeze
@scopes = [(outer_scope || {})]
@registers = registers
@registers = registers.is_a?(StaticRegisters) ? registers : StaticRegisters.new(registers)
@errors = []
@partial = false
@strict_variables = false
@@ -39,6 +39,10 @@ module Liquid
@global_filter = nil
@disabled_tags = {}
@registers.static[:cached_partials] ||= {}
@registers.static[:file_system] ||= Liquid::Template.file_system
@registers.static[:template_factory] ||= Liquid::TemplateFactory.new
self.exception_renderer = Template.default_exception_renderer
if rethrow_errors
self.exception_renderer = Liquid::RAISE_EXCEPTION_LAMBDA