Make partial_cache a configurable option

This commit is contained in:
Ian Ker-Seymer
2024-09-23 15:40:49 -04:00
parent b233b3d081
commit 62c9cd88e1
6 changed files with 25 additions and 10 deletions
+10 -4
View File
@@ -22,11 +22,17 @@ class RenderTagTest < Minitest::Test
end
def test_render_passes_named_arguments_into_inner_scope
partial_cache = Class.new do
def load(template_name, context:, parse_context:)
Liquid::Template.parse("my own partial cache (#{template_name})")
end
end.new
environment = Liquid::Environment.build(partial_cache: partial_cache)
assert_template_result(
'My Product',
'{% render "product", inner_product: outer_product %}',
{ 'outer_product' => { 'title' => 'My Product' } },
partials: { 'product' => '{{ inner_product.title }}' },
'my own partial cache (my_partial.liquid)',
'{% render "my_partial.liquid" %}',
environment: environment,
)
end
+2 -2
View File
@@ -40,10 +40,10 @@ module Minitest
def assert_template_result(
expected, template, assigns = {},
message: nil, partials: nil, error_mode: nil, render_errors: false,
template_factory: nil
template_factory: nil, environment: nil
)
file_system = StubFileSystem.new(partials || {})
environment = Liquid::Environment.build(file_system: file_system)
environment ||= Liquid::Environment.build(file_system: file_system)
template = Liquid::Template.parse(template, line_numbers: true, error_mode: error_mode&.to_sym, environment: environment)
registers = Liquid::Registers.new(file_system: file_system, template_factory: template_factory)
context = Liquid::Context.build(static_environments: assigns, rethrow_errors: !render_errors, registers: registers, environment: environment)