Skip to content

Commit 266e1ed

Browse files
committed
Remove ... syntax references
1 parent 8c963c9 commit 266e1ed

File tree

3 files changed

+290
-921
lines changed

3 files changed

+290
-921
lines changed

lib/liquid/lexer.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class Lexer
1717
DASH = [:dash, "-"].freeze
1818
DOT = [:dot, "."].freeze
1919
DOTDOT = [:dotdot, ".."].freeze
20-
DOTDOTDOT = [:dotdotdot, "..."].freeze
2120
DOT_ORD = ".".ord
2221
DOUBLE_STRING_LITERAL = /"[^\"]*"/
2322
EOS = [:end_of_string].freeze
@@ -114,15 +113,10 @@ def tokenize(ss)
114113

115114
if (special = SPECIAL_TABLE[peeked])
116115
ss.scan_byte
117-
# Special case for ".." and "..."
116+
# Special case for ".."
118117
if special == DOT && ss.peek_byte == DOT_ORD
119118
ss.scan_byte
120-
if ss.peek_byte == DOT_ORD
121-
ss.scan_byte
122-
output << DOTDOTDOT
123-
else
124-
output << DOTDOT
125-
end
119+
output << DOTDOT
126120
elsif special == DASH
127121
# Special case for negative numbers
128122
if (peeked_byte = ss.peek_byte) && NUMBER_TABLE[peeked_byte]

lib/liquid/tags/render.rb

Lines changed: 8 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,7 @@ def render_tag(context, output)
7676
inner_context['forloop'] = forloop if forloop
7777

7878
@attributes.each do |key, value|
79-
if key.start_with?("...") && is_inline
80-
if key == "..."
81-
context.scopes.each do |scope|
82-
scope.each do |k, v|
83-
inner_context[k] = v
84-
end
85-
end
86-
else
87-
obj = context.evaluate(value)
88-
if obj.is_a?(Liquid::Drop)
89-
(obj.class.invokable_methods - ['to_liquid']).each do |method_name|
90-
inner_context[method_name] = obj.invoke_drop(method_name)
91-
end
92-
elsif obj.is_a?(Hash)
93-
obj.each do |k, v|
94-
inner_context[k] = v
95-
end
96-
else
97-
raise ::ArgumentError
98-
end
99-
end
100-
else
101-
inner_context[key] = context.evaluate(value)
102-
end
79+
inner_context[key] = context.evaluate(value)
10380
end
10481

10582
inner_context[context_variable_name] = var unless var.nil?
@@ -142,23 +119,11 @@ def rigid_parse(markup)
142119
p.consume?(:comma)
143120

144121
@attributes = {}
145-
while p.look(:dotdotdot) || p.look(:id)
146-
if p.consume?(:dotdotdot)
147-
if p.look(:id)
148-
identifier = p.read(:id)
149-
key = "...#{identifier}"
150-
@attributes.delete(key)
151-
@attributes[key] = safe_parse_expression(p)
152-
else
153-
@attributes.delete("...")
154-
@attributes["..."] = true
155-
end
156-
else
157-
key = p.consume
158-
p.consume(:colon)
159-
@attributes.delete(key)
160-
@attributes[key] = safe_parse_expression(p)
161-
end
122+
while p.look(:id)
123+
key = p.consume
124+
p.consume(:colon)
125+
@attributes[key] = safe_parse_expression(p)
126+
162127
p.consume?(:comma) # optional comma
163128
end
164129

@@ -190,20 +155,8 @@ def lax_parse(markup)
190155
@is_for_loop = (with_or_for == FOR)
191156

192157
@attributes = {}
193-
markup.scan(/(\.\.\.)(\w+)?(?=\s|,|$)|#{TagAttributes.source}/) do |spread, identifier, key, value|
194-
if spread
195-
if identifier
196-
spread_key = "...#{identifier}"
197-
@attributes.delete(spread_key)
198-
@attributes[spread_key] = parse_expression(identifier)
199-
else
200-
@attributes.delete("...")
201-
@attributes["..."] = true
202-
end
203-
elsif key && value
204-
@attributes.delete(key)
205-
@attributes[key] = parse_expression(value)
206-
end
158+
markup.scan(TagAttributes) do |key, value|
159+
@attributes[key] = parse_expression(value)
207160
end
208161
end
209162

0 commit comments

Comments
 (0)