Sha256: 6c9dcb1aeb410b7fa4d06c85f8d2107fb7b473487a3526d630a804f469e34517

Contents?: true

Size: 777 Bytes

Versions: 7

Compression:

Stored size: 777 Bytes

Contents

# 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

      template_factory = (context.registers[:template_factory] ||= Liquid::TemplateFactory.new)
      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

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
liquid-5.3.0 lib/liquid/partial_cache.rb
liquid-5.2.0 lib/liquid/partial_cache.rb
liquid-5.1.0 lib/liquid/partial_cache.rb
liquid-5.0.1 lib/liquid/partial_cache.rb
liquid-5.0.0 lib/liquid/partial_cache.rb
liquid-render-tag-0.2.0 lib/liquid-render-tag/partial_cache.rb
liquid-render-tag-0.1.0 lib/liquid-render-tag/partial_cache.rb