mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
add name attribute to Template for more flexibility to set context's template name
This commit is contained in:
@@ -268,12 +268,14 @@ class RenderTagTest < Minitest::Test
|
||||
def test_render_tag_renders_actual_template_name_for_error
|
||||
original_file_system = Liquid::Template.file_system
|
||||
|
||||
Liquid::Template.file_system = MemoryFileSystem.new(
|
||||
context = Liquid::Context.new('errors' => ErrorDrop.new)
|
||||
|
||||
context.registers[:file_system] = MemoryFileSystem.new(
|
||||
'/some/path/snippets/foo.liquid' => "{{ foo.standard_error }}",
|
||||
)
|
||||
|
||||
template = Liquid::Template.parse("{% render 'foo' with errors %}", line_numbers: true)
|
||||
assert_equal('Liquid error (/some/path/snippets/foo line 1): standard error', template.render('errors' => ErrorDrop.new))
|
||||
assert_equal('Liquid error (/some/path/snippets/foo line 1): standard error', template.render(context))
|
||||
ensure
|
||||
Liquid::Template.file_system = original_file_system
|
||||
end
|
||||
|
||||
+1
-1
@@ -233,6 +233,6 @@ class MemoryFileSystem
|
||||
end
|
||||
|
||||
def actual_template_name(template_name)
|
||||
@snippets[template_name][:actual_template_name]
|
||||
@snippets[template_name][:actual_template_name].delete_suffix(".liquid")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user