Extract method for raising a syntax error in the assign tag for liquid-c (#1321)

This commit is contained in:
Dylan Thacker-Smith
2020-10-20 16:59:52 -04:00
committed by GitHub
parent ae6bd9f6b0
commit c9ad9d338c
+8 -3
View File
@@ -12,15 +12,20 @@ module Liquid
class Assign < Tag
Syntax = /(#{VariableSignature}+)\s*=\s*(.*)\s*/om
# @api private
def self.raise_syntax_error(parse_context)
raise Liquid::SyntaxError, parse_context.locale.t('errors.syntax.assign')
end
attr_reader :to, :from
def initialize(tag_name, markup, options)
def initialize(tag_name, markup, parse_context)
super
if markup =~ Syntax
@to = Regexp.last_match(1)
@from = Variable.new(Regexp.last_match(2), options)
@from = Variable.new(Regexp.last_match(2), parse_context)
else
raise SyntaxError, options[:locale].t('errors.syntax.assign')
self.class.raise_syntax_error(parse_context)
end
end