diff --git a/lib/liquid/lexer.rb b/lib/liquid/lexer.rb index 94a3d9fa..f1740dba 100644 --- a/lib/liquid/lexer.rb +++ b/lib/liquid/lexer.rb @@ -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] diff --git a/lib/liquid/tags/render.rb b/lib/liquid/tags/render.rb index a6fd0c48..55ab7d3f 100644 --- a/lib/liquid/tags/render.rb +++ b/lib/liquid/tags/render.rb @@ -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 diff --git a/test/integration/tags/snippet_test.rb b/test/integration/tags/snippet_test.rb index 18b41ad4..1476f9da 100644 --- a/test/integration/tags/snippet_test.rb +++ b/test/integration/tags/snippet_test.rb @@ -205,6 +205,49 @@ class SnippetTest < Minitest::Test assert_template_result(expected, template) end + def test_render_snippets_as_arguments + template = <<~LIQUID.strip + {% assign color_scheme = 'dark' %} + + {% snippet header %} +