tests passing

This commit is contained in:
Josh Faigan
2024-10-01 14:23:55 -04:00
parent 3399981b89
commit f3270183a7
2 changed files with 36 additions and 10 deletions
+5 -4
View File
@@ -69,15 +69,16 @@ module Liquid
# Inline snippets take precedence over external snippets
if (inline_snippet = context.registers[:inline_snippet][template_name])
inner_context = context.new_isolated_subcontext
# binding.irb
snippet_body = inline_snippet[:body]
snippet_args = inline_snippet[:args]
# Validate and set the arguments in the inner context
@attributes.each do |key, value|
if snippet_args.include?(key)
inner_context[key] = context.evaluate(value)
unless snippet_args.include?(key)
raise Liquid::ArgumentError, "Invalid argument `#{key}` for snippet `#{template_name}`"
end
inner_context[key] = context.evaluate(value)
end
return output << snippet_body.render(inner_context)