mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 18:30:40 -07:00
Render arguments should maintain correct precedence
This commit is contained in:
committed by
Guilherme Carreiro
parent
489a03118c
commit
65fb80a347
@@ -40,6 +40,7 @@ module Liquid
|
|||||||
QuotedString = /"[^"]*"|'[^']*'/
|
QuotedString = /"[^"]*"|'[^']*'/
|
||||||
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
||||||
TagAttributes = /(\w[\w-]*)\s*\:\s*(#{QuotedFragment})/o
|
TagAttributes = /(\w[\w-]*)\s*\:\s*(#{QuotedFragment})/o
|
||||||
|
ContextInheritance = /\.\.\./
|
||||||
AnyStartingTag = /#{TagStart}|#{VariableStart}/o
|
AnyStartingTag = /#{TagStart}|#{VariableStart}/o
|
||||||
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om
|
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/om
|
||||||
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om
|
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/om
|
||||||
|
|||||||
+18
-24
@@ -42,10 +42,6 @@ module Liquid
|
|||||||
@is_for_loop
|
@is_for_loop
|
||||||
end
|
end
|
||||||
|
|
||||||
def inherit_context?
|
|
||||||
@inherit_context
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_to_output_buffer(context, output)
|
def render_to_output_buffer(context, output)
|
||||||
render_tag(context, output)
|
render_tag(context, output)
|
||||||
end
|
end
|
||||||
@@ -77,20 +73,21 @@ module Liquid
|
|||||||
inner_context.partial = true
|
inner_context.partial = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if is_inline && inherit_context?
|
inner_context['forloop'] = forloop if forloop
|
||||||
context.scopes.each do |scope|
|
|
||||||
scope.each do |key, value|
|
@attributes.each do |key, value|
|
||||||
inner_context[key] = value
|
if key == "..." && is_inline
|
||||||
|
context.scopes.each do |scope|
|
||||||
|
scope.each do |k, v|
|
||||||
|
inner_context[k] = v
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
inner_context[key] = context.evaluate(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@attributes.each do |key, value|
|
|
||||||
inner_context[key] = context.evaluate(value)
|
|
||||||
end
|
|
||||||
|
|
||||||
inner_context[context_variable_name] = var unless var.nil?
|
inner_context[context_variable_name] = var unless var.nil?
|
||||||
inner_context['forloop'] = forloop if forloop
|
|
||||||
|
|
||||||
partial.render_to_output_buffer(inner_context, output)
|
partial.render_to_output_buffer(inner_context, output)
|
||||||
forloop&.send(:increment!)
|
forloop&.send(:increment!)
|
||||||
@@ -119,14 +116,6 @@ module Liquid
|
|||||||
|
|
||||||
p.consume?(:comma)
|
p.consume?(:comma)
|
||||||
|
|
||||||
@inherit_context = false
|
|
||||||
# ... inline snippets syntax
|
|
||||||
if p.consume?(:dotdotdot)
|
|
||||||
p.consume?(:comma)
|
|
||||||
|
|
||||||
@inherit_context = true
|
|
||||||
end
|
|
||||||
|
|
||||||
@attributes = {}
|
@attributes = {}
|
||||||
while p.look(:id)
|
while p.look(:id)
|
||||||
key = p.consume
|
key = p.consume
|
||||||
@@ -162,11 +151,16 @@ module Liquid
|
|||||||
@variable_name_expr = variable_name ? parse_expression(variable_name) : nil
|
@variable_name_expr = variable_name ? parse_expression(variable_name) : nil
|
||||||
@template_name_expr = parse_expression(template_name)
|
@template_name_expr = parse_expression(template_name)
|
||||||
@is_for_loop = (with_or_for == FOR)
|
@is_for_loop = (with_or_for == FOR)
|
||||||
@inherit_context = markup.include?('...')
|
|
||||||
|
|
||||||
@attributes = {}
|
@attributes = {}
|
||||||
markup.scan(TagAttributes) do |key, value|
|
markup.scan(/(#{ContextInheritance})|#{TagAttributes.source}/) do |context_marker, key, value|
|
||||||
@attributes[key] = parse_expression(value)
|
if context_marker
|
||||||
|
@attributes.delete("...")
|
||||||
|
@attributes["..."] = true
|
||||||
|
elsif key && value
|
||||||
|
@attributes.delete(key)
|
||||||
|
@attributes[key] = parse_expression(value)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+1106
-425
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user