mirror of
https://github.com/Shopify/liquid.git
synced 2025-07-17 00:00:10 -04:00
Compare commits
No commits in common. "c44d1d9193f16789ee4972ac9ff6990f53d70662" and "cca24a2226f22d17c30eb0d08e59efb03eb4d8ad" have entirely different histories.
c44d1d9193
...
cca24a2226
@ -4,8 +4,7 @@ module Liquid
|
||||
class PartialCache
|
||||
def self.load(template_name, context:, parse_context:)
|
||||
cached_partials = context.registers[:cached_partials]
|
||||
cache_key = "#{template_name}:#{parse_context.error_mode}"
|
||||
cached = cached_partials[cache_key]
|
||||
cached = cached_partials[template_name]
|
||||
return cached if cached
|
||||
|
||||
file_system = context.registers[:file_system]
|
||||
@ -25,7 +24,7 @@ module Liquid
|
||||
|
||||
partial.name ||= template_name
|
||||
|
||||
cached_partials[cache_key] = partial
|
||||
cached_partials[template_name] = partial
|
||||
ensure
|
||||
parse_context.partial = false
|
||||
end
|
||||
|
@ -174,27 +174,4 @@ class PartialCacheUnitTest < Minitest::Test
|
||||
|
||||
assert_equal('some/path/my_partial', partial.name)
|
||||
end
|
||||
|
||||
def test_includes_error_mode_into_template_cache
|
||||
template_factory = StubTemplateFactory.new
|
||||
context = Liquid::Context.build(
|
||||
registers: {
|
||||
file_system: StubFileSystem.new('my_partial' => 'my partial body'),
|
||||
template_factory: template_factory,
|
||||
},
|
||||
)
|
||||
|
||||
[:lax, :warn, :strict].each do |error_mode|
|
||||
Liquid::PartialCache.load(
|
||||
'my_partial',
|
||||
context: context,
|
||||
parse_context: Liquid::ParseContext.new(error_mode: error_mode),
|
||||
)
|
||||
end
|
||||
|
||||
assert_equal(
|
||||
["my_partial:lax", "my_partial:warn", "my_partial:strict"],
|
||||
context.registers[:cached_partials].keys,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user