From e753b9025de12c60e453a96bbe4b8305a9802d4b Mon Sep 17 00:00:00 2001 From: Julia Boutin Date: Tue, 4 Nov 2025 13:11:18 -0700 Subject: [PATCH] Ensure render tag checks for most common type first Previously, render tag would check if a template responded to `:to_partial` before checking if its name was a string. As `is_a?(String)` instances are more common that `to_partial`, this commit reorders the conditional to follow the common path --- lib/liquid/tags/render.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/liquid/tags/render.rb b/lib/liquid/tags/render.rb index dec725ed..a01bb764 100644 --- a/lib/liquid/tags/render.rb +++ b/lib/liquid/tags/render.rb @@ -49,14 +49,14 @@ module Liquid def render_tag(context, output) template = context.evaluate(@template_name_expr) - if template.respond_to?(:to_partial) - partial = template.to_partial - template_name = template.filename - context_variable_name = @alias_name || template.name - elsif @template_name_expr.is_a?(String) + if @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 + elsif template.respond_to?(:to_partial) && template.respond_to?(:name) + partial = template.to_partial + template_name = template.filename + context_variable_name = @alias_name || template.name else raise ::ArgumentError end