mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-26 13:45:13 -07:00
Extract /\w+:0x\h{8}/ regex to UNNAMED_CYCLE_PATTERN constant
This commit is contained in:
committed by
Guilherme Carreiro
parent
e57b7efe4e
commit
44f0429c08
@@ -17,6 +17,7 @@ module Liquid
|
|||||||
class Cycle < Tag
|
class Cycle < Tag
|
||||||
SimpleSyntax = /\A#{QuotedFragment}+/o
|
SimpleSyntax = /\A#{QuotedFragment}+/o
|
||||||
NamedSyntax = /\A(#{QuotedFragment})\s*\:\s*(.*)/om
|
NamedSyntax = /\A(#{QuotedFragment})\s*\:\s*(.*)/om
|
||||||
|
UNNAMED_CYCLE_PATTERN = /\w+:0x\h{8}/
|
||||||
|
|
||||||
attr_reader :variables
|
attr_reader :variables
|
||||||
|
|
||||||
@@ -86,7 +87,7 @@ module Liquid
|
|||||||
|
|
||||||
unless @is_named
|
unless @is_named
|
||||||
@name = @variables.to_s
|
@name = @variables.to_s
|
||||||
@is_named = !@name.match?(/\w+:0x\h{8}/)
|
@is_named = !@name.match?(UNNAMED_CYCLE_PATTERN)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ module Liquid
|
|||||||
when SimpleSyntax
|
when SimpleSyntax
|
||||||
@variables = variables_from_string(markup)
|
@variables = variables_from_string(markup)
|
||||||
@name = @variables.to_s
|
@name = @variables.to_s
|
||||||
@is_named = !@name.match?(/\w+:0x\h{8}/)
|
@is_named = !@name.match?(UNNAMED_CYCLE_PATTERN)
|
||||||
else
|
else
|
||||||
raise SyntaxError, options[:locale].t("errors.syntax.cycle")
|
raise SyntaxError, options[:locale].t("errors.syntax.cycle")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user