mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 08:15:41 +03:00
* Enabled frozen string literals * Update rubocop config * Prefer string interpolation in simple cases Co-Authored-By: Dylan Thacker-Smith <dylan.smith@shopify.com>
21 lines
629 B
Ruby
21 lines
629 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] ||= Liquid::Template.file_system)
|
|
source = file_system.read_template_file(template_name)
|
|
parse_context.partial = true
|
|
|
|
partial = Liquid::Template.parse(source, parse_context)
|
|
cached_partials[template_name] = partial
|
|
ensure
|
|
parse_context.partial = false
|
|
end
|
|
end
|
|
end
|