mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 17:30:43 -07:00
Make partial_cache a configurable option
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user