mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 19:00:39 -07:00
Merge pull request #465 from Shopify/avoid_multi_assigns
Avoid parallel assignments
This commit is contained in:
@@ -11,7 +11,8 @@ class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
|||||||
private
|
private
|
||||||
|
|
||||||
def handle(type, req, res)
|
def handle(type, req, res)
|
||||||
@request, @response = req, res
|
@request = req
|
||||||
|
@response = res
|
||||||
|
|
||||||
@request.path_info =~ /(\w+)\z/
|
@request.path_info =~ /(\w+)\z/
|
||||||
@action = $1 || 'index'
|
@action = $1 || 'index'
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ module Liquid
|
|||||||
attr_accessor :left, :operator, :right
|
attr_accessor :left, :operator, :right
|
||||||
|
|
||||||
def initialize(left = nil, operator = nil, right = nil)
|
def initialize(left = nil, operator = nil, right = nil)
|
||||||
@left, @operator, @right = left, operator, right
|
@left = left
|
||||||
|
@operator = operator
|
||||||
|
@right = right
|
||||||
@child_relation = nil
|
@child_relation = nil
|
||||||
@child_condition = nil
|
@child_condition = nil
|
||||||
end
|
end
|
||||||
@@ -47,11 +49,13 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def or(condition)
|
def or(condition)
|
||||||
@child_relation, @child_condition = :or, condition
|
@child_relation = :or
|
||||||
|
@child_condition = condition
|
||||||
end
|
end
|
||||||
|
|
||||||
def and(condition)
|
def and(condition)
|
||||||
@child_relation, @child_condition = :and, condition
|
@child_relation = :and
|
||||||
|
@child_condition = condition
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach(attachment)
|
def attach(attachment)
|
||||||
@@ -94,7 +98,8 @@ module Liquid
|
|||||||
# return this as the result.
|
# return this as the result.
|
||||||
return context[left] if op == nil
|
return context[left] if op == nil
|
||||||
|
|
||||||
left, right = context[left], context[right]
|
left = context[left]
|
||||||
|
right = context[right]
|
||||||
|
|
||||||
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
|
operation = self.class.operators[op] || raise(Liquid::ArgumentError.new("Unknown operator #{op}"))
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ module Liquid
|
|||||||
def lax_parse(markup)
|
def lax_parse(markup)
|
||||||
@filters = []
|
@filters = []
|
||||||
if markup =~ /(#{QuotedFragment})(.*)/om
|
if markup =~ /(#{QuotedFragment})(.*)/om
|
||||||
name_markup, filter_markup = $1, $2
|
name_markup = $1
|
||||||
|
filter_markup = $2
|
||||||
@name = Expression.parse(name_markup)
|
@name = Expression.parse(name_markup)
|
||||||
if filter_markup =~ /#{FilterSeparator}\s*(.*)/om
|
if filter_markup =~ /#{FilterSeparator}\s*(.*)/om
|
||||||
filters = $1.scan(FilterParser)
|
filters = $1.scan(FilterParser)
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ class StrainerUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation
|
def test_strainer_uses_a_class_cache_to_avoid_method_cache_invalidation
|
||||||
a, b = Module.new, Module.new
|
a = Module.new
|
||||||
|
b = Module.new
|
||||||
strainer = Strainer.create(nil, [a,b])
|
strainer = Strainer.create(nil, [a,b])
|
||||||
assert_kind_of Strainer, strainer
|
assert_kind_of Strainer, strainer
|
||||||
assert_kind_of a, strainer
|
assert_kind_of a, strainer
|
||||||
|
|||||||
Reference in New Issue
Block a user