Missing inline snippets should display same error as filebased

This commit is contained in:
Julia Boutin
2025-10-30 12:00:44 +01:00
committed by Guilherme Carreiro
parent 5ceb0e9cec
commit 12fd93fbe2
6 changed files with 106 additions and 14 deletions
+2
View File
@@ -34,3 +34,5 @@
render: "Argument error in tag 'render' - Dynamically chosen templates are not allowed"
disabled:
tag: "usage is not allowed in this context"
file_system:
includes: "This liquid context does not allow includes"
+3 -2
View File
@@ -2,12 +2,13 @@
module Liquid
class SnippetDrop < Drop
attr_reader :body, :name
attr_reader :body, :name, :filename
def initialize(body, name)
def initialize(body, name, filename)
super()
@body = body
@name = name
@filename = filename
end
def to_partial
+4 -4
View File
@@ -51,16 +51,16 @@ module Liquid
if template.respond_to?(:to_partial)
partial = template.to_partial
template_name = template.name
template_name = template.filename
context_variable_name = @alias_name || template.name
elsif @template_name_expr.is_a?(String)
partial = PartialCache.load(template, context: context, parse_context: parse_context)
template_name = partial.name
context_variable_name = @alias_name || template_name.split('/').last
else
raise ::ArgumentError, parse_context.locale.t("errors.argument.render")
raise Liquid::ArgumentError, parse_context.locale.t("errors.file_system.includes")
end
context_variable_name = @alias_name || template_name.split('/').last
render_partial_func = ->(var, forloop) {
inner_context = context.new_isolated_subcontext
inner_context.template_name = template_name
+1 -1
View File
@@ -26,7 +26,7 @@ module Liquid
end
def render_to_output_buffer(context, output)
snippet_drop = SnippetDrop.new(@body, @to)
snippet_drop = SnippetDrop.new(@body, @to, context.template_name)
context.scopes.last[@to] = snippet_drop
context.resource_limits.increment_assign_score(assign_score_of(snippet_drop))
output