mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 00:40:40 -07:00
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]>
25 lines
699 B
Ruby
25 lines
699 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Liquid
|
|
class PartialCache
|
|
def self.load(template_name, context:, parse_context:)
|
|
cached_partials = context.registers[:cached_partials]
|
|
cached = cached_partials[template_name]
|
|
return cached if cached
|
|
|
|
file_system = context.registers[:file_system]
|
|
source = file_system.read_template_file(template_name)
|
|
|
|
parse_context.partial = true
|
|
|
|
template_factory = context.registers[:template_factory]
|
|
template = template_factory.for(template_name)
|
|
|
|
partial = template.parse(source, parse_context)
|
|
cached_partials[template_name] = partial
|
|
ensure
|
|
parse_context.partial = false
|
|
end
|
|
end
|
|
end
|