mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Remove ... syntax references
This commit is contained in:
committed by
Guilherme Carreiro
parent
40e45e32ac
commit
0cc6cdd553
+2
-8
@@ -17,7 +17,6 @@ module Liquid
|
||||
DASH = [:dash, "-"].freeze
|
||||
DOT = [:dot, "."].freeze
|
||||
DOTDOT = [:dotdot, ".."].freeze
|
||||
DOTDOTDOT = [:dotdotdot, "..."].freeze
|
||||
DOT_ORD = ".".ord
|
||||
DOUBLE_STRING_LITERAL = /"[^\"]*"/
|
||||
EOS = [:end_of_string].freeze
|
||||
@@ -114,15 +113,10 @@ module Liquid
|
||||
|
||||
if (special = SPECIAL_TABLE[peeked])
|
||||
ss.scan_byte
|
||||
# Special case for ".." and "..."
|
||||
# Special case for ".."
|
||||
if special == DOT && ss.peek_byte == DOT_ORD
|
||||
ss.scan_byte
|
||||
if ss.peek_byte == DOT_ORD
|
||||
ss.scan_byte
|
||||
output << DOTDOTDOT
|
||||
else
|
||||
output << DOTDOT
|
||||
end
|
||||
output << DOTDOT
|
||||
elsif special == DASH
|
||||
# Special case for negative numbers
|
||||
if (peeked_byte = ss.peek_byte) && NUMBER_TABLE[peeked_byte]
|
||||
|
||||
@@ -76,30 +76,7 @@ module Liquid
|
||||
inner_context['forloop'] = forloop if forloop
|
||||
|
||||
@attributes.each do |key, value|
|
||||
if key.start_with?("...") && is_inline
|
||||
if key == "..."
|
||||
context.scopes.each do |scope|
|
||||
scope.each do |k, v|
|
||||
inner_context[k] = v
|
||||
end
|
||||
end
|
||||
else
|
||||
obj = context.evaluate(value)
|
||||
if obj.is_a?(Liquid::Drop)
|
||||
(obj.class.invokable_methods - ['to_liquid']).each do |method_name|
|
||||
inner_context[method_name] = obj.invoke_drop(method_name)
|
||||
end
|
||||
elsif obj.is_a?(Hash)
|
||||
obj.each do |k, v|
|
||||
inner_context[k] = v
|
||||
end
|
||||
else
|
||||
raise ::ArgumentError
|
||||
end
|
||||
end
|
||||
else
|
||||
inner_context[key] = context.evaluate(value)
|
||||
end
|
||||
inner_context[key] = context.evaluate(value)
|
||||
end
|
||||
|
||||
inner_context[context_variable_name] = var unless var.nil?
|
||||
@@ -132,23 +109,11 @@ module Liquid
|
||||
p.consume?(:comma)
|
||||
|
||||
@attributes = {}
|
||||
while p.look(:dotdotdot) || p.look(:id)
|
||||
if p.consume?(:dotdotdot)
|
||||
if p.look(:id)
|
||||
identifier = p.read(:id)
|
||||
key = "...#{identifier}"
|
||||
@attributes.delete(key)
|
||||
@attributes[key] = safe_parse_expression(p)
|
||||
else
|
||||
@attributes.delete("...")
|
||||
@attributes["..."] = true
|
||||
end
|
||||
else
|
||||
key = p.consume
|
||||
p.consume(:colon)
|
||||
@attributes.delete(key)
|
||||
@attributes[key] = safe_parse_expression(p)
|
||||
end
|
||||
while p.look(:id)
|
||||
key = p.consume
|
||||
p.consume(:colon)
|
||||
@attributes[key] = safe_parse_expression(p)
|
||||
|
||||
p.consume?(:comma) # optional comma
|
||||
end
|
||||
|
||||
@@ -180,20 +145,8 @@ module Liquid
|
||||
@is_for_loop = (with_or_for == FOR)
|
||||
|
||||
@attributes = {}
|
||||
markup.scan(/(\.\.\.)(\w+)?(?=\s|,|$)|#{TagAttributes.source}/) do |spread, identifier, key, value|
|
||||
if spread
|
||||
if identifier
|
||||
spread_key = "...#{identifier}"
|
||||
@attributes.delete(spread_key)
|
||||
@attributes[spread_key] = parse_expression(identifier)
|
||||
else
|
||||
@attributes.delete("...")
|
||||
@attributes["..."] = true
|
||||
end
|
||||
elsif key && value
|
||||
@attributes.delete(key)
|
||||
@attributes[key] = parse_expression(value)
|
||||
end
|
||||
markup.scan(TagAttributes) do |key, value|
|
||||
@attributes[key] = parse_expression(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user