mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user